|
Expression | Matches |
| [abc] |
A single character: a, b, or c |
| [^abc] |
Any single character but a, b, or c |
| [a-z] |
Any character in the range a-z |
| [a-zA-Z] |
Any character in the range a-z or A-Z (any alphabetical character) |
| \s |
Any whitespace character [ \t\n\r\f\v] |
| \S |
Any non-whitespace character [^ \t\n\r\f\v] |
| \d |
Any digit [0-9] |
| \D |
Any non-digit [^0-9] |
| \w |
Any word character [a-zA-Z0-9_] |
| \W |
Any non-word character [^a-zA-Z0-9_] |
| \b |
A word boundary between \w and \W |
| \B |
A position that is not a word boundary |
| | |
Alternation: matches either the subexpression to the left or to the right |
| () |
Grouping: group all together for repetition operators |
| ^ |
Beginning of the string |
| $ |
End of the string |