Character Classes
| . | Any character (except newline) |
| \d | Digit [0-9] |
| \D | Non-digit |
| \w | Word char [a-zA-Z0-9_] |
| \W | Non-word char |
| \s | Whitespace |
| \S | Non-whitespace |
| [abc] | Character set |
| [^abc] | Negated set |
| [a-z] | Range |
Anchors
| ^ | Start of string/line |
| $ | End of string/line |
| \b | Word boundary |
| \B | Non-word boundary |
Quantifiers
| * | 0 or more |
| + | 1 or more |
| ? | 0 or 1 |
| {n} | Exactly n |
| {n,} | n or more |
| {n,m} | Between n and m |
| *? | Lazy (non-greedy) |
Groups & Lookaround
| (abc) | Capturing group |
| (?:abc) | Non-capturing group |
| (?<name>) | Named group |
| \1 | Backreference |
| a|b | Alternation |
| (?=abc) | Positive lookahead |
| (?!abc) | Negative lookahead |
| (?<=abc) | Positive lookbehind |
| (?<!abc) | Negative lookbehind |
Flags
| g | Global - find all matches |
| i | Case-insensitive |
| m | Multiline (^ $ match lines) |
| s | DotAll (. matches \n) |
| u | Unicode support |
Replacement
| $& | Entire match |
| $1, $2 | Captured group |
| $` | Before match |
| $' | After match |
| $$ | Literal $ |