LAST UPDATED: DECEMBER 29, 2025
A pattern normally matches characters in the input string. Anchors do not match characters. Instead, they limit where the pattern is allowed to begin or end in the input. If the pattern is not in the required position, the match fails.
Start Anchors
The ^ anchor requires the pattern to begin at the start of the input string. If any characters appear before the pattern, the match fails.
Examples - Start Anchor
EXAMPLE 1
Input:
CODE
{{ 'D3 Security' | regex_match('^D3') }}
{{ ' D3 Security' | regex_match('^D3') }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D3 Security' | regex_match('^[^0-9]') }}
{{ '3D Security' | regex_match('^[^0-9]') }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 'D3 Security' | regex_match('^[A-Z][0-9]') }}
{{ 'Management System' | regex_match('^[A-Z][0-9]') }}
Return Data:
EXAMPLE 4
Input:
CODE
{{ 'Security Management' | regex_match('^\w') }}
{{ ' Security Management' | regex_match('^\w') }}
Return Data:
End Anchors
The $ anchor requires the pattern to end at the end of the input string. If any characters appear after the pattern, the match fails.
Examples - End Anchor
EXAMPLE 1
Input:
CODE
{{ 'D3' | regex_match('Security$') }}
{{ 'D3 Security' | regex_match('Security$') }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D3' | regex_match('[0-9]$') }}
{{ 'D3 Security' | regex_match('[0-9]$') }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 'D3' | regex_match('[^0-9]$') }}
{{ 'D3 Security' | regex_match('[^0-9]$') }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 'D3 Security' | regex_match('\w$') }}
{{ 'D3 Security ' | regex_match('\w$') }}
Return Data:
Start and End Anchors
Using the ^ and $ anchors together requires the entire input string to match the pattern exactly. No characters are allowed before or after the pattern.
Examples - Start and End Anchors
EXAMPLE 1
Input:
CODE
{{ 'D3' | regex_match('^D3 Security$') }}
{{ 'D3 Security' | regex_match('^D3 Security$') }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D3' | regex_match('^[A-Z][0-9]$') }}
{{ 'd3' | regex_match('^[A-Z][0-9]$') }}
{{ ' D3' | regex_match('^[A-Z][0-9]$') }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 'D3' | regex_match('^[^A-Z][0-9]$') }}
{{ 'd3' | regex_match('^[^A-Z][0-9]$') }}
{{ ' D3' | regex_match('^[^A-Z][0-9]$') }}
Return Data:
EXAMPLE 4
Input:
CODE
{{ 'D3' | regex_match('^\w\d$') }}
{{ 'D3 ' | regex_match('^\w\d$') }}
The input must be exactly one word character (a letter, decimal digit, or underscore) followed by one digit, for the match to succeed.
Return Data:
Word and Non-Word Boundaries
Word Boundaries
A word boundary anchor, expressed by \\b, matches a position between word and non-word characters, allowing patterns to match whole words but not substrings within larger words.
Examples - Word Boundaries
EXAMPLE 1
Input:
CODE
{{ 'D3' | regex_match('\\bD3') }}
{{ 'D3' | regex_match('D3\\b') }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D3!' | regex_match('!\\b') }}
{{ 'D3!Security' | regex_match('!\\b') }}
{{ 'D3_Security' | regex_match('_\\b') }}
{{ 'D3🛡️Security' | regex_match('🛡️\\b') }}
{{ 'D3 Security' | regex_match(' \\b') }}
Return Data:
CODE
False
True
False
True
True
EXAMPLE 3
Input:
CODE
{{ 'D3 Security' | regex_match('\\BD3 ') }}
{{ 'D3 Security' | regex_match(' Security\\b') }}
{{ 'D3 Security' | regex_match('\\BD3 Security\\b') }}
\\B is the non-word-boundary anchor.
Return Data:
Non-Word Boundaries
A non-word boundary anchor, expressed by \\B, matches a position that is not between word and non-word characters, allowing patterns to match substrings within larger words while preventing matches at word boundaries.
Examples - Non-Word Boundary
EXAMPLE 1
Input:
CODE
{{ 'D3' | regex_match('\\BD3') }}
{{ 'D3' | regex_match('D3\\B') }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D3!' | regex_match('!\\B') }}
{{ 'D3!Security' | regex_match('!\\B') }}
{{ 'D3_Security' | regex_match('_\\B') }}
{{ 'D3🛡️Security' | regex_match('🛡️\\B') }}
{{ 'D3 Security' | regex_match(' \\B') }}
Return Data:
CODE
True
False
True
False
False
EXAMPLE 3
Input:
CODE
{{ 'D3 Security' | regex_match('\\BD3 ') }}
{{ 'D3 Security' | regex_match(' Security\\b') }}
{{ 'D3 Security' | regex_match('\\BD3 Security\\b') }}
\\b is the #WordBoundaries.
Return Data: