LAST UPDATED: DECEMBER 22, 2025
A character class, expressed by characters enclosed in [], allows multiple possible characters at a specific position in a pattern. A pattern can contain multiple character classes, each matching a single character in the input text.
Literal Characters
Any single character listed inside the [] can match an input character, at the corresponding position.
Examples - Literal Characters
EXAMPLE 1
Input:
CODE
{{ "D3" | regex_match("[ABCD]") }}
{{ "D3" | regex_match("[abcd]") }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ "D3" | regex_match("d[1234]") }}
{{ "D3" | regex_match("d[5678]") }}
{{ "D3" | regex_match("D[1234]") }}
{{ "D3" | regex_match("D[5678]") }}
Return Data:
CODE
False
False
True
False
EXAMPLE 3
Input:
CODE
{{ "click here" | regex_match("[ ]") }}
{{ "click here" | regex_match("[ ]") }}
Explanation: In the first input, the character between "click" and "here" is U+2006 SIX-PER-EM SPACE, not the ASCII space character (U+0020).
Return Data:
EXAMPLE 4
Input:
CODE
{{ "𝗌ecure" | regex_match("[𝗌]") }}
{{ "securе" | regex_match("[𝗌]") }}
Explanation: [𝗌] matches the mathematical sans-serif small 𝗌 (U+1D5CC).
Return Data:
EXAMPLE 5
Input:
CODE
{{ "docuмent.exe" | regex_match("docu[м]ent") }}
{{ "document.exe" | regex_match("docu[м]ent") }}
Explanation: [м] matches the Cyrillic character м (U+043C).
Return Data:
EXAMPLE 6
Input:
CODE
{{ "Google" | regex_match("[ѻ]") }}
{{ "Gѻѻgle" | regex_match("[ѻ]") }}
Explanation: [ѻ] matches the literal Cyrillic character ѻ (U+047B).
Return Data:
EXAMPLE 7
Input:
CODE
{{ "apple.com" | regex_match("[a]pple") }}
{{ "apple.com" | regex_match("[a]pple") }}
Explanation: [a] matches the fullwidth character a (U+FF41).
Return Data:
EXAMPLE 8
Input:
CODE
{{ "cmd.exe /c whoami & net user Ryan /add" | regex_match("[&]") }}
Return Data:
Ranges
A contiguous sequence of characters (i.e., range) is expressed using a - in the format [start-end]. Multiple ranges may be included within the same []. The ranges within a [] matches exactly one character whose Unicode code point falls within the specified bounds, inclusive. Ranges may be combined with literal characters, which can appear before, between, or after ranges.
Sample Range Types
SEMANTIC NOTE
Ranges are based on the underlying integer character code.
ASCII Lowercase Ranges *
EXAMPLES
Entire alphabet: [a-z]
Subranges: [a-g], [m-r], [u-z]
Unioned subranges: [a-fm-s], [a-cx-z], [a-dh-kp-v]
ASCII Uppercase Ranges *
EXAMPLES
Entire alphabet: [A-Z]
Subranges: [A-G], [M-R], [U-Z]
Unioned subranges: [A-FM-S], [A-CX-Z], [A-DH-KP-V]
ASCII Digit Ranges *
EXAMPLES
All digits: [0-9]
Subranges: [0-3], [4-7], [7-9]
Unioned subranges: [0-35-7], [1-26-8], [0-47-9]
ASCII Mixed Ranges *
EXAMPLES
Uppercase + lowercase: [A-Za-z]
Shorter combined spans: [A-Ga-g], [M-Rm-r], [U-Zu-z]
Multiple combined spans: [A-FM-Sa-fm-s], [A-CX-Za-cx-z], [A-DH-KP-Va-dh-kp-v]
Latin Lowercase Ranges *
EXAMPLES
Full code-point range: [a-ž]
Subranges: [á-ř], [č-ň], [š-ž]
Unioned subranges: [a-řu-ž], [á-čě-ň], [č-ťž]
Latin Uppercase Ranges *
EXAMPLES
Full code-point range: [A-Ž]
Subranges: [Á-Ř], [Č-Ň], [Š-Ž]
Unioned subranges: [A-ŘU-Ž], [Á-ČĚ-Ň], [Č-ŤŽ]
Latin Mixed Ranges *
EXAMPLES
Uppercase + lowercase: [A-Ža-ž]
Shorter combined spans: [Á-Řá-ř], [Č-Ňč-ň], [Š-Žš-ž]
Multiple combined spans: [A-Řa-řU-Žu-ž], [Á-Čá-čĚ-Ňě-ň], [Č-Ťč-ťŠ-Žš]
Cyrillic Lowercase Ranges *
EXAMPLES
Full code-point range: [а-я]
Subranges: [д-п], [р-ч], [ж-н]
Unioned subranges: [а-ео-я], [д-йл-н], [ж-пт-я]
Cyrillic Uppercase Ranges *
EXAMPLES
Full code-point range: [А-Я]
Subranges: [Д-П], [Р-Ч], [Ж-Н]
Unioned subranges: [А-ЕО-Я], [Д-ЙЛ-Н], [Ж-ПТ-Я]
Cyrillic Mixed Ranges *
EXAMPLES
Uppercase + lowercase: [А-Яа-я]
Shorter combined spans: [Д-Пд-п], [Р-Чр-ч], [Ж-Нж-н]
Multiple combined spans: [А-Еа-еО-Яо-я], [Д-Йд-йЛ-Нл-н], [Ж-Пж-пТ-Ят-я]
Devanagari Letter Ranges *
EXAMPLES
Full code-point range: [ऀ-ॿ]
Subranges: [अ-औ], [क-ह], [ट-न], [प-य], [र-ळ]
Unioned subranges: [अ-औक-ह], [क-गत-न], [ट-नप-भ], [अ-इक-गप-भ]
Devanagari Consonant Ranges *
EXAMPLES
Primary consonants: [क-ह]
Subranges: [क-च], [ट-थ], [प-भ]
Unioned subranges: [क-घट-थ], [क-छप-भ], [ट-नय-ळ]
Devanagari Vowel Ranges *
EXAMPLES
Independent vowels: [अ-औ]
Subranges: [अ-ऊ], [ए-औ]
Unioned subranges: [अ-इए-ओ], [अ-ऊए-ऐ]
Dependent vowel signs: [ा-ौ]
Subranges: [ा-ी], [े-ै]
Unioned subranges: [ा-ीे-ै]
Devanagari Digit Ranges *
EXAMPLES
All digits: [०-९]
Subranges: [०-४], [५-७], [७-९]
Unioned subranges: [०-२४-६], [१-३५-९], [०-४७-९]
Devanagari Mixed Ranges *
EXAMPLES
Letters and digits: [अ-औ०-९], [क-ह०-४]
Letters and vowel signs: [क-हा-ी], [अ-औे-ै]
Consonants, vowels, digits: [अ-औक-ह०-९], [क-गअ-इ३-५]
Multiple mixed spans: [अ-इक-घ५-७], [क-घट-न०-३], [अ-औक-ढ०-९]
Chinese Ranges *
EXAMPLES
Full code-point range: [一-龯]
Subranges: [木-林], [河-海], [花-草], [金-銅]
Unioned subranges: [日-月水-火], [山-川田-禾]
Japanese Hiragana Ranges *
EXAMPLES
Full code-point range: [ぁ-ゟ]
Subranges: [か-そ], [た-の], [は-ほ]
Unioned subranges: [ぁ-ゑを-ゟ], [か-しな-の], [た-とま-も]
Japanese Katakana Ranges *
EXAMPLES
Full code-point range: [ァ-ヿ], [ㇰ-ㇿ]
Subranges: [カ-ソ], [タ-ノ], [ハ-ホ], [ㇰ-ㇶ], [ㇷ-ㇿ]
Unioned subranges: [ァ-ヱヲ-ヿ], [カ-セタ-ト], [ナ-ノマ-モ], [ㇰ-ㇲㇴ-ㇿ]
Japanese Mixed Ranges *
EXAMPLES
Hiragana + Katakana: [ぁ-ゟァ-ヿ]
Shorter mixed spans: [か-そカ-ソ], [た-のタ-ノ]
Multiple mixed spans: [ぁ-ゑァ-ヱを-ゟヲ-ヿ]
Korean (Hangul) Ranges *
EXAMPLES
Full code-point range: [가-힣], [ᄀ-ᇿ], [ㄱ-ㆎ]
Subranges: [가-딯], [따-뛳], [라-맇], [ᄀ-ᄋ], [ᄌ-ᄒ], [ㄱ-ㄷ], [ㅂ-ㅅ]
Unioned subranges: [가-나다-랃], [카-킿파-핗], [ᄀ-ᄈᄋ-ᄒ], [ㄱ-ㄴㅁ-ㅂ], [ㅅ-ㅇㅈ-ㅊ]
Arabic Letter Ranges *
EXAMPLES
Full code-point range: [ء-ي]
Subranges: [ا-ه], [ب-خ], [س-ف], [ق-ل], [م-ي]
Unioned subranges: [ا-خب-ذ], [س-قك-م], [ب-حث-ص]
Arabic Digit Ranges *
EXAMPLES
All digits: [٠-٩]
Subranges: [٠-٤], [٥-٧], [٧-٩]
Unioned subranges: [٠-٢٤-٦], [١-٣٥-٩], [٠-٤٧-٩]
Arabic Mixed Ranges *
EXAMPLES
Letters and digits: [ا-ه٠-٩], [م-ي٢-٣]
Letters with internal spans: [ب-حث-ص], [ا-خب-ذ]
Letters + digits: [ب-حث-ص٥-٧]
Greek Lowercase Ranges *
EXAMPLES
Full code-point range: [α-ω]
Subranges: [β-ζ], [η-μ], [ν-σ], [τ-ψ]
Unioned subranges: [α-δε-ζ], [η-θλ-ξ], [ν-σφ-ψ]
Greek Uppercase Ranges *
EXAMPLES
Full code-point range: [Α-Ω]
Subranges: [Β-Ζ], [Η-Μ], [Ν-Σ], [Τ-Φ]
Unioned subranges: [Α-ΔΗ-Κ], [Β-ΘΜ-Ρ], [Ν-ΣΤ-Φ]
Greek Mixed Ranges *
EXAMPLES
Uppercase + lowercase: [Α-Ωα-ω]
Shorter combined spans: [Β-Ζβ-ζ], [Η-Μη-μ], [Ν-Σν-σ]
Unioned combined spans: [Α-Δα-δΗ-Κη-κ], [Β-Θβ-θΜ-Ρμ-ρ]
Hebrew Ranges *
EXAMPLES
Full code-point range: [א-ת]
Subranges: [ב-ח], [ט-ע], [פ-ת]
Unioned subranges: [א-דט-מ], [ב-זפ-צ], [ח-יכ-ס]
Mixed Hebrew spans: [א-תך-ץ], [ב-חך-ם], [ט-פף-ץ]
Examples - Ranges
EXAMPLE 1
Input:
CODE
{{ 'D' | regex_match('[a-z]') }}
{{ '3' | regex_match('[A-Z]') }}
{{ 'Security' | regex_match('S[d-f]curity') }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D' | regex_match('[0-9a-zA-Z]') }}
{{ '3' | regex_match('[0-9a-zA-Z]') }}
{{ '_' | regex_match('[0-9a-zA-Z]') }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ '-' | regex_match('[-0-9a-zA-Z]') }}
{{ '!' | regex_match('[0-9!a-zA-Z]') }}
{{ '@' | regex_match('[0-9a-z@A-Z]') }}
{{ '#' | regex_match('[0-9a-zA-Z#]') }}
Return Data:
EXAMPLE 4
Input:
CODE
{{ '192.168.200.8' | regex_match('192\.168\.200\.[0-9][0-9]') }}
{{ '192.168.200.30' | regex_match('192\.168\.200\.[0-9][0-9]') }}
{{ '192.168.200.100' | regex_match('192\.168\.200\.1[0-9][0-9]') }}
{{ '192.168.200.100' | regex_match('192\.168\.200\.1[5-9][5-9]') }}
{{ '192.168.200.188' | regex_match('192\.168\.200\.1[5-9][5-9]') }}
Return Data:
CODE
False
True
True
False
True
EXAMPLE 5
Input:
CODE
{{ 's' | regex_match('[a-řu-ž]') }}
{{ 'д' | regex_match('[а-я]') }}
{{ 'क' | regex_match('[क-ह]') }}
{{ '林' | regex_match('[河-海]') }}
{{ 'た' | regex_match('[か-そ]') }}
{{ '한' | regex_match('[가-힣]') }}
{{ 'ق' | regex_match('[ق-ل]') }}
{{ 'Ж' | regex_match('[Α-Ωα-ω]') }}
{{ 'ך' | regex_match('[א-תך-ץ]') }}
Return Data:
CODE
True
True
True
False
False
True
True
False
True
Negations
Negation is expressed using a ^ immediately after the opening bracket, in the format [^chars], to match any single character not listed in the []. If the ^ appears in any other position, it is treated as a literal character.
Examples - Negations
EXAMPLE 1
Input:
CODE
{{ 'D' | regex_match('[^0-9]') }}
{{ '3' | regex_match('[^0-9]') }}
{{ 'D3' | regex_match('[^0-9]') }}
{{ 'D3' | regex_match('D[^0-9]') }}
Return Data:
CODE
True
False
True
False
EXAMPLE 2
Input:
CODE
{{ '!' | regex_match('[^A-Za-z0-9]') }}
{{ 'D3' | regex_match('D[^A-Za-z0-9]') }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ '192.168.1.1' | regex_match('192[^!@#]168') }}
{{ '192.168.1.1' | regex_match('192[^,./]168') }}
Return Data:
EXAMPLE 4
Input:
CODE
{{ '^' | regex_match('[^^]') }}
{{ '^' | regex_match('[^]-_]') }}
Return Data:
See 005D to 005F.
Shorthand Classes
Shorthand classes are abbreviated forms of longer character class expressions. Each shorthand class has a corresponding negated form.
Digits
\d – Matches a decimal digit from 0 through 9. It is the same as [0-9].
\D – Matches any character that is not a decimal digit from 0 through 9. It is the same as [^0-9].
Examples - Shorthand Digits
EXAMPLE 1
Input:
CODE
{{ '3' | regex_match('\d') }}
{{ 'D' | regex_match('\d') }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D' | regex_match('\D') }}
{{ '3' | regex_match('\D') }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 'D3 Security' | regex_match('D\d [Security]') }}
{{ 'D3 Security' | regex_match('D\D [Security]') }}
Return Data:
Whitespaces
\s – Matches a whitespace character. It is the same as [ \t\n\r\f\v].
\S – Matches any character that is not whitespace. It is the same as [^ \t\n\r\f\v].
Examples - Shorthand Whitespaces
EXAMPLE 1
Input:
CODE
{{ 'D' | regex_match('\s') }}
{{ '3' | regex_match('\s') }}
{{ ' ' | regex_match('\s') }}
{{ '\t' | regex_match('\s') }}
{{ '\n' | regex_match('\s') }}
{{ '\r' | regex_match('\s') }}
{{ '\f' | regex_match('\s') }}
{{ '\v' | regex_match('\s') }}
Return Data:
CODE
False
False
True
True
True
True
True
True
EXAMPLE 2
Input:
CODE
{{ 'D' | regex_match('\S') }}
{{ '3' | regex_match('\S') }}
{{ ' ' | regex_match('\S') }}
{{ '\t' | regex_match('\S') }}
{{ '\n' | regex_match('\S') }}
{{ '\r' | regex_match('\S') }}
{{ '\f' | regex_match('\S') }}
{{ '\v' | regex_match('\S') }}
Return Data:
CODE
True
True
False
False
False
False
False
False
EXAMPLE 3
Input:
CODE
{{ 'D3 Security' | regex_match('\S\S\s\S\S\S\S\S\S\S') }}
Return Data:
Word Characters
\w – Matches a letter, decimal digit, or underscore. It is the same as [A-Za-z0-9_].
\W – Matches any character that is not a word character. It is the same as [^A-Za-z0-9_].
Examples - Shorthand Words
EXAMPLE 1
Input:
CODE
{{ 'D' | regex_match('\w') }}
{{ 'd' | regex_match('\w') }}
{{ '3' | regex_match('\w') }}
{{ '_' | regex_match('\w') }}
{{ ' ' | regex_match('\w') }}
{{ '!' | regex_match('\w') }}
Return Data:
CODE
True
True
True
True
False
False
EXAMPLE 2
Input:
CODE
{{ 'D' | regex_match('\W') }}
{{ 'd' | regex_match('\W') }}
{{ '3' | regex_match('\W') }}
{{ '_' | regex_match('\W') }}
{{ ' ' | regex_match('\W') }}
{{ '!' | regex_match('\W') }}
Return Data:
CODE
False
False
False
False
True
True
EXAMPLE 3
Input:
CODE
{{ 'D3 Security' | regex_match('\w\w\W\w\w\w\w\w\w\w') }}
Return Data:
Special Cases
Some characters require specific placement or escaping to be treated literally:
] – Must be placed immediately after [, unless escaped.
- – Must be placed at the start or end, unless escaped.
^ – Must not be placed immediately after [, unless escaped.
Examples - Special Cases
EXAMPLE 1
Input:
CODE
{{ ']' | regex_match('[]]') }}
{{ ']' | regex_match('[ ]]') }}
{{ ']' | regex_match('[ \]]') }}
Return Data:
Explanation: [ ]] matches a characters that is either a space (' '), or a closing square bracket (']').
EXAMPLE 2
Input:
CODE
{{ '-' | regex_match('[-a-z]') }}
{{ '-' | regex_match('[a-z]') }}
{{ '-' | regex_match('[a\-z]') }}
{{ '-' | regex_match('[a-z-]') }}
Return Data:
CODE
True
False
True
True
EXAMPLE 3
Input:
CODE
{{ '^' | regex_match('[\^]') }}
{{ '^' | regex_match('[^^]') }}
{{ '^' | regex_match('[ ^]') }}
Return Data:
Explanation: In the pattern [^^], the caret (^) appears directly after [, so it negates the character class. The pattern therefore matches any single character except ^.
Troubleshooting
Error: "bad character range <range> at position <#>"
This error message means that the system has detected an invalid range definition inside a character class. Ranges must be ordered from a lower code point to a higher code point.
EXAMPLE 1
Input:
CODE
{{ 'd' | regex_match('[z-a]') }}
Error:
CODE
bad character range z-a at position 1
EXAMPLE 2
Input:
CODE
{{ 'D3' | regex_match('D[9-0]') }}
Error:
CODE
bad character range 9-0 at position 2