.
Any character (except newline; with /s flag, also newline)
\d
Any digit (0-9)
\D
Any non-digit
\w
Word character (a-z, A-Z, 0-9, _)
\W
Non-word character
\s
Whitespace (space, tab, newline)
\S
Non-whitespace
\b
Word boundary
^ $
Start / end of string (or line, with /m flag)
*
Zero or more of the previous element
+
One or more of the previous element
?
Zero or one of the previous element (optional)
{n,m}
Between n and m of the previous element
(...)
Capture group — saved into $1, $2, …
(?:...)
Non-capture group — useful for alternation without capturing
(?<n>...)
Named capture group — referenced as $<n>
[abc]
Character class — any one of a, b, or c
[^abc]
Negated character class — any character except a, b, c
a|b
Alternation — match either a or b
(?=...)
Positive lookahead — followed by
(?!...)
Negative lookahead — not followed by
(?<=...)
Positive lookbehind — preceded by
(?<!...)
Negative lookbehind — not preceded by
$1 $<n>
Backreference in replace string — numbered or named