Basics
*
Match preceding character 0 or more times
+
Match preceding character 1 or more times
.
Match any single character
x|y
Match either 'x' or 'y'
\
Escape a special character
b
The character b
abc
The string abc
Character Classes I
\d
Match a digit character
\D
Match a non-digit character
\s
Match a single white space character (space, tab, form feed, or line feed)
\S
Match a single character other than white space
\w
Match any alphanumeric character (including underscore)
\W
Match any non-word character
Character Classes II
[abc]
Match any one of the characters in the set 'abc'
[^abc]
Match anything not in character set 'abc'
[\b]
Match a backspace
Assertions
^
Match beginning of input
$
Match end of input
\b
Match a word boundary
\B
Match a non-word boundary
?=
Lookahead
?!
Negative lookahead
Assertions II
?<=
Lookbehind
?<!
Negative lookbehind
?>
Once-only subexpression
?()
If then condition
?()|
If then else condition
?#
Comment
Quantifiers
{n}
Match exactly n occurrences of preceding character
{n,m}
Match at least n and at most m occurrences of the preceding character
?
Match 0 or 1
Special Characters I
\cX
Match control character X in a string
\n
Match a line feed
\r
Match a carriage return
\t
Match a tab
\0
Match a NULL
Special Characters II
\f
Match a form feed
\v
Match a vertical tab
\xhh
Match character with code hh (2 hex digits)
\uhhhh
Match character with code hhhh (4 hex digits)
Flags
g
Global search
i
Case-insensitive search
m
Multi-line search
y
"sticky" search match starting at current position in target string
Groups
(x)
Match 'x' and remember the match
(?:x)
Match 'x' but do not remember the match
\n
A back reference to the last substring matching the n parenthetical in the regex