Module Information |
|
Common Tokens |
. |
Any character except newline |
a |
The character 'a' |
ab |
The string 'ab' |
a|b |
The character 'a' or 'b' |
*a |
0 or more characters 'a' |
\ |
Escapes a special character |
|
Quantifiers |
* |
0 or more |
+ |
1 or more |
? |
0 or 1 |
{2} |
Exactly 2 |
{2,5} |
Between 2 and 5 |
{2,} |
2 or more |
(,5} |
Up to 5 |
|
Groups |
(...) |
Capturing group |
(?P<foo>) |
Capturing group named 'foo' |
(?:...) |
Non-capturing group |
\Y |
Match the Y'th captured group |
(?P=foo) |
Match the named group 'foo' |
(?#...) |
Comment |
|
Character Classes |
[ad-f] |
One character of: a, d, e, f |
[^ad-f] |
One character except: a, d, e, f |
\s |
Any whitespace character |
\S |
Any non-whitespace character |
\d |
Any digit |
\D |
Any non-digit |
\w |
Any word character |
\W |
Any non-word character |
|
Assertions |
^ |
Start of string |
$ |
End of string |
\b |
Any word boundary |
\B |
Any non-word boundary |
(?=...) |
Positive lookahead |
(?!...) |
Negative lookahead |
(?<=...) |
Positive lookbehind |
(?(foo)yes|no) |
Conditional match for capturing group 'foo' |
|
Flags |
(?aiLmsux) |
One or more letters from the flags below |
(?a) |
ASCII-only matching |
(?i) |
Ignore case |
(?L) |
Locale dependent |
(?m) |
Multi-line |
(?s) |
dot matches all |
(?u) |
Unicode matching |
(?x) |
Verbose |
|
Special Characters |
\n |
Newline |
\r |
Carriage return |
\t |
Tab |
\YYY |
Octal character 'YYY' |
\xYY |
Hexadecimal character 'YY' |
|
Replacement |
\g<0> |
Insert entire match |
\g<foo> |
Insert match 'foo' |
\Y |
Insert group numbered Y |
|