Quick reference
Special characters definitions
\ Quotes the next meta character
^ Match the beginning of a line
. Match any character (except newline character)
$ Match the end of a line
| Alternation
() Group
[] Character class
* Match 0 or more times
+ Match 1 or more times
? Match 0 or 1 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but no more than m times
Character classes
[abc] a, b, or c (simple class)
[^abc] Any character except a, b, or c (negation)
[a-zA-Z] a through z, or A through Z, inclusive (range)
[a-d[m-p]] a through d, or m through p: [a-dm-p] (union)
[a-z&&[def]] d, e, or f (intersection)
[a-z&&[^bc]] a through z, except b and c: [ad-z] (subtraction)
[a-z&&[^m-p]] a through z, but excluding m through p: [a-lq-z] (subtraction)
Pre-defined character classes
. Any character (except newline character)
\d A digit character: [0-9]
\D A non-digit character: [^0-9]
\s A whitespace character: [ \t\n\x0B\f\r]
\S A non-whitespace character: [^\s]
\w A word character: [a-zA-Z_0-9]
\W A non-word character: [^\w]