Ordinary characters |
Characters other than . $ ^ { [ ( | ) * + ? \ match themselves. |
. |
Matches any character excluding the line feed. Includes the line feed in single-line mode. |
[abc] |
A character class (may contain more than one character). Matches any character that is contained within the brackets, in no particular order. |
[^abc] |
The opposite of [ ]. Matches all characters not contained within the brackets. |
[a-z] |
Character range: Matches any single character in the range from first (a) to last (z). |
\w |
Matches an alpha-numeric character (a-z, A-Z, 0-9, and underscore). |
\W |
The opposite of \w. Matches any non-alphanumeric character. |
\d |
Matches a decimal character (0-9). |
\D |
The opposite of \d. Matches any non-decimal character. |
\s |
Matches a character of whitespace (space, tab, carriage return, line feed). |
\S |
The opposite of \s. Matches any non-whitespace character. |
\r |
Matches a carriage return. |
\n |
Matches a new line (line feed). |
\f |
Matches a form feed. |
\t |
Matches a tab. |
\v |
Matches a vertical tab. |
\a |
Matches a bell character. |
\b |
In a character class, matches a backspace. |
\e |
Matches an escape. |
\040 |
Uses octal representation to specify a character (octal consists of up to three digits). |
\x20 |
Uses hexadecimal representation to specify a character (hex consists of exactly two digits). |
\c0003 |
Matches the specified 4-digit ASCII control character. |
\u0020 |
Matches a Unicode character by using hexadecimal representation (exactly four digits). |
\p{name} |
Matches any single character in the Unicode general category or named block specified by name. |
\P{name} |
Matches any single character that is not in the Unicode general category or named block specified by name. |
\ |
In front of any of the special characters (. $ ^ { [ ( | ) * + ? \), this will match the character itself. |