Skip to main content
Skip table of contents

Anchors

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:

CODE
True
False

EXAMPLE 2

Input:

CODE
{{ 'D3 Security' | regex_match('^[^0-9]') }}
{{ '3D Security' | regex_match('^[^0-9]') }}

Return Data:

CODE
True
False

EXAMPLE 3

Input:

CODE
{{ 'D3 Security' | regex_match('^[A-Z][0-9]') }}
{{ 'Management System' | regex_match('^[A-Z][0-9]') }}

Return Data:

CODE
True
False

EXAMPLE 4

Input:

CODE
{{ 'Security Management' | regex_match('^\w') }}
{{ ' Security Management' | regex_match('^\w') }}

Return Data:

CODE
True
False

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:

CODE
False
True

EXAMPLE 2

Input:

CODE
{{ 'D3' | regex_match('[0-9]$') }}
{{ 'D3 Security' | regex_match('[0-9]$') }}

Return Data:

CODE
True
False

EXAMPLE 3

Input:

CODE
{{ 'D3' | regex_match('[^0-9]$') }}
{{ 'D3 Security' | regex_match('[^0-9]$') }}

Return Data:

CODE
False
True

EXAMPLE 3

Input:

CODE
{{ 'D3 Security' | regex_match('\w$') }}
{{ 'D3 Security ' | regex_match('\w$') }}

Return Data:

CODE
True
False

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:

CODE
False
True

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:

CODE
True
False
False

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:

CODE
False
True
False

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:

CODE
True
False

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:

CODE
True
True

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:

CODE
False
True
False

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:

CODE
False
False

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:

CODE
False
True
False
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.