r" "
MATCHES
REFERENCE
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
(?a) ASCII-only matching (SCOPED)
(?f) Fullcase (SCOPED)
(?i) Ignore case (SCOPED)
(?L) Locale dependent (SCOPED)
(?m) Multi-line (SCOPED)
(?s) dot matches all (SCOPED)
(?u) Unicode matching (SCOPED)
(?x) Verbose (SCOPED)
(?w) Word (SCOPED)
(?b) Best match (GLOBAL)
(?e) Enhance match (GLOBAL)
(?p) POSIX (GLOBAL)
(?r) Reverse (GLOBAL)
(?V0) Version 0 (re compatible)
(?V1) Version 1 (New behavior)
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