| Construct |
Matches |
| x |
| \\ |
| \0n |
| \0nn |
| \0mnn |
| \xhh |
| \uhhhh |
| \t |
| \n |
| \r |
| \f |
| \a |
| \e |
| \cx |
|
| Characters |
| The character x |
| The backslash character |
| The character with octal value 0n (0 <= n <= 7) |
| The character with octal value 0nn (0 <= n <= 7) |
| The character with octal value 0mnn (0 <= m <= 3, 0 <= n <= 7) |
| The character with hexadecimal value 0xhh |
| The character with hexadecimal value 0xhhhh |
| The tab character ('\u0009') |
| The newline (line feed) character ('\u000A') |
| The carriage-return character ('\u000D') |
| The form-feed character ('\u000C') |
| The alert (bell) character ('\u0007') |
| The escape character ('\u001B') |
| The control character corresponding to x |
|
| [abc] |
| [^abc] |
| [a-zA-Z] |
| [a-d[m-p]] |
| [a-z&&[def]] |
| [a-z&&[^bc]] |
| [a-z&&[^m-p]] |
|
| Character Classes |
| Any character except a, b, or c (negation) |
| a through z or A through Z, inclusive (range) |
| a through d, or m through p: [a-dm-p] (union) |
| d, e, or f (intersection) |
| a through z, except for b and c: [ad-z] (subtraction) |
| a through z, and not m through p: [a-lq-z](subtraction) |
|
|
|
| Predefined Character Classes |
| Any character (may or may not match line terminators) |
| A digit: [0-9] |
| A non-digit: [^0-9] |
| A whitespace character: [ \t\n\x0B\f\r] |
| A non-whitespace character: [^\s] |
| A word character: [a-zA-Z_0-9] |
| A non-word character: [^\w] |
|
| \p{Lower} |
| \p{Upper} |
| \p{ASCII} |
| \p{Alpha} |
| \p{Digit} |
| \p{Alnum} |
| \p{Punct} |
| \p{Graph} |
| \p{Print} |
| \p{Blank} |
| \p{Cntrl} |
| \p{XDigit} |
| \p{Space} |
|
| POSIX character classes (US-ASCII only) |
| A lower-case alphabetic character: [a-z] |
| An upper-case alphabetic character:[A-Z] |
| All ASCII:[\x00-\x7F] |
| An alphabetic character:[\p{Lower}\p{Upper}] |
| A decimal digit: [0-9] |
| An alphanumeric character:[\p{Alpha}\p{Digit}] |
| A visible character: [\p{Alnum}\p{Punct}] |
| A printable character: [\p{Graph}\x20] |
| A space or a tab: [ \t] |
| A control character: [\x00-\x1F\x7F] |
| A hexadecimal digit: [0-9a-fA-F] |
| A whitespace character: [ \t\n\x0B\f\r] |
|
| \p{InGreek} |
| \p{Lu} |
| \p{Sc} |
| \P{InGreek} |
| [\p{L}&&[^\p{Lu}]] |
|
| Classes for Unicode blocks and categories |
| A character in the Greek block (simple block) |
| An uppercase letter (simple category) |
| A currency symbol |
| Any character except one in the Greek block (negation) |
| Any letter except an uppercase letter (subtraction) |
|
|
|
| Boundary Matchers |
| The beginning of a line |
| The end of a line |
| A word boundary |
| A non-word boundary |
| The beginning of the input |
| The end of the previous match |
| The end of the input but for the final terminator, if any |
| The end of the input |
|
| X? |
| X* |
| X+ |
| X{n} |
| X{n,} |
| X{n,m} |
|
| Greedy Quantifiers |
| X, once or not at all |
| X, zero or more times |
| X, one or more times |
| X, exactly n times |
| X, at least n times |
| X, at least n but not more than m times |
|
| X?? |
| X*? |
| X+? |
| X{n}? |
| X{n,}? |
| X{n,m}? |
|
| Reluctant Quantifiers |
| X, once or not at all |
| X, zero or more times |
| X, one or more times |
| X, exactly n times |
| X, at least n times |
| X, at least n but not more than m times |
|
| X++ |
| X*+ |
| X++ |
| X{n}+ |
| X{n,}+ |
| X{n,m}+ |
|
| Possessive Quantifiers |
| X, once or not at all |
| X, zero or more times |
| X, one or more times |
| X, exactly n times |
| X, at least n times |
| X, at least n but not more than m times |
|
|
|
| Logical Operators |
| X followed by Y |
| Either X or Y |
| X, as a capturing group |
|
|
|
| Back References |
| Whatever the nth capturing group matched |
|
|
|
| Quotation |
| Nothing, but quotes the following character |
| Nothing, but quotes all characters until \E |
| Nothing, but ends quoting started by \Q |
|
| (?:X) |
| (?idmsux-idmsux) |
| (?idmsux-idmsux:X) |
| (?=X) |
| (?!X) |
| (?<=X) |
| (?<!X) |
| (?>X) |
|
| Special Constructs (non-capturing) |
| Nothing, but turns match flags on - off |
| X, as a non-capturing group with the given flags on - off |
| X, via zero-width positive lookahead |
| X, via zero-width negative lookahead |
| X, via zero-width positive lookbehind |
| X, via zero-width negative lookbehind |
| X, as an independent, non-capturing group |
|