Regex quick overview
Parsing group contains blocks intended to process input data. Input data are processed using blocks, which work with regular expressions. More information about the regular expressions is available on: https://en.wikipedia.org/wiki/Regular_expression
Logmanager guarantees only the syntax listed on this page. Syntax marked as not supported and syntax that isn’t listed may be rejected, accepted, or interpreted differently in any version. For details and rewrites, see Unsupported regex constructs.
Regular expressions basics:
| regular expression | description |
|---|---|
. |
Any character except newline |
a |
The character a |
ab |
The string ab |
a|b |
a or b |
a* |
0 or more a’s |
\ |
Escapes an ASCII punctuation character, for example \. or \- |
\t, \n, \r, \f, \v |
Tab, line feed, carriage return, form feed, vertical tab |
\xHH |
Character with the hexadecimal code HH, for example \xe9 for é |
Regular Expression Quantifiers:
| regular expression | description |
|---|---|
* |
0 or more |
+ |
1 or more |
? |
0 or 1 |
{2} |
Exactly 2 |
{2,5} |
Between 2 and 5 |
{2,} |
2 or more |
{0,5} |
Up to 5 |
*?, +?, ??, {2,5}? |
As above, but as few as possible |
The maximum count in {...} is 1000, including nested counts: their product must not exceed 1000.
Regular Expression Groups:
| regular expression | description |
|---|---|
(...) |
Capturing group |
(?P<Y>...) |
Capturing group named Y. Y contains only A-Z, a-z, 0-9, and _, and doesn’t start with a digit |
(?:...) |
Non-capturing group |
\Y |
Match the Y’th captured group, not supported |
(?P=Y) |
Match the named group Y, not supported |
(?#...) |
Comment, not supported |
Regular Expression Character Classes:
| regular expression | description |
|---|---|
[ab-d] |
One character of: a, b, c, d |
[^ab-d] |
One character except: a, b, c, d |
[\d\s\w.] |
Inside brackets, you can use \d, \s, \w, their negations, \xHH, and escaped punctuation |
[[:alpha:]] |
POSIX character class, not supported, use a range such as [A-Za-z] |
[\b] |
Backspace character, not supported, use \x08 |
\d |
One digit, ASCII only ([0-9]) |
\D |
One non-digit |
\s |
One whitespace, ASCII only ([\t\n\f\r ]) |
\S |
One non-whitespace |
\w |
One word character, ASCII only ([0-9A-Za-z_]) |
\W |
One non-word character |
Regular Expression Assertions:
| regular expression | description |
|---|---|
^ |
Start of string |
\A |
Start of string, ignores m flag |
$ |
End of string. A newline at the end isn’t skipped. To allow one, write \n?$ |
\Z |
End of string, ignores m flag, not supported |
\b |
Word boundary, ASCII only |
\B |
Non-word boundary |
(?=...) |
Positive lookahead, not supported |
(?!...) |
Negative lookahead, not supported |
(?<=...) |
Positive lookbehind, not supported |
(?<!...) |
Negative lookbehind, not supported |
(?()|) |
Conditional, not supported |
Regular Expression Flags:
| regular expression | description |
|---|---|
(?i) |
Case-insensitive matching |
(?m) |
^ and $ also match at line breaks |
(?s) |
. also matches a newline |
(?i:...), (?m:...), (?s:...) |
The flag applies only inside the group |
Write (?i), (?m), and (?s) only at the very start of the regex. If several blocks are connected to by regex, the regex starts with the first block. Anywhere else, use the group form, for example user=(?i:admin). In a Regex assign substitution, always use the group form, for example (?i:admin), because the substitution is wrapped in a named group.