engine,
providing safe and efficient pattern matching capabilities.
It supports standard regular expression syntax but does not support backtracking,
ensuring stable and predictable performance.
| Single-character Expression Type | Example |
|---|
| Any character (including newline if s=true) | . |
| Character class | [xyz] |
| Negated character class | [^xyz] |
| Perl character class | \d |
| Negated Perl character class | \D |
| ASCII character class | [[:alpha:]] |
| Negated ASCII character class | [[:^alpha:]] |
| Unicode character class (single letter) | \pN |
| Unicode character class | \p{Greek} |
| Negated Unicode character class | \PN |
| Negated Unicode character class | \P{Greek} |
| Composite Expressions | Meaning |
|---|
xy | x followed by y |
x|y | x or y (prefer x) |
| Grouping Expressions | Description |
|---|
(re) | Capturing group |
(?P<name>re) | Named capturing group |
(?:re) | Non-capturing group |
| Escape Sequences | Description |
|---|
\n | Newline |
\t | Tab |
\x7F | Hex character |
\Q...\E | Literal text |
| Repetition Expressions | Meaning |
|---|
x* | 0 or more x (greedy) |
x*? | 0 or more x (lazy) |
x+ | 1 or more x (greedy) |
x+? | 1 or more x (lazy) |
x? | 0 or 1 x (prefer 1) |
x?? | 0 or 1 x (prefer 0) |
x{n,m} | n to m x (greedy) |
x{n,} | at least n x |
x{n} | exactly n x |
Note: The maximum limit for counting forms like x{n,m} is 1000.
| Flags | Description |
|---|
i | Case-insensitive (default: false). e.g. (?i)hello matches "hello" and "Hello". |
m | Multi-line mode: ^ and $ match the start and end of each line as well as the whole text (default: false) e.g. (?m)^b.* matches “banana” in "apple\nbanana\ncherry". |
s | Allows . to match newline \n (default: false). e.g. (?s)start(.*)end matches "start B \n new line \n end" |
U | Ungreedy mode switch: swaps meanings of x* and x*?, x+ and x+?, etc. (default: false) Reversal: x* becomes lazy, x*? becomes greedy, x+ becomes lazy, x+? becomes greedy. e.g. text:="a123b456b" comparison: (?U)a.*b → “a123b” (lazy, stops at first b)a.*b → “a123b456b” (greedy, matches as much as possible)
|
| Anchors (Zero-width) | Description |
|---|
^ | Start of text or line |
$ | End of text or line |
\A | Start of text |
\b | Word boundary (one side is \w and the other is \W or start/end) |
\z | End of text (end of entire string, e.g. world\z matches "hello\nworld") |