Show Menu
Cheatography

Regular Expression Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Characters

.
Any Character (Except New Line)
\d
Digit (0-9)
\D
Not a Digit (0-9)
\w
Word Character (a-z, A-Z, 0-9)
\W
Not a Word Character
\s
Whitespace (space, tab, newline)
\S
Not Whitespace

Anchors and Boundaries

\b
Word Boundary
\B
Not a Word Boundary
^
Beginning of a String
$
End of a String

Character Classes

[]
Matches Characters in brackets
[^]
Matches Characters not in brackets
|
Either or
( )
Group

Quanti­fiers

?
0 or 1
*
0 or More
+
1 or More
{3}
Exact Number
{3,4}
Range of Numbers {Min, Max}
{3,}
Min or More
 

Special Characters

.^$*+?­{}[]\()
Those characters need to be escaped.

Logic

|
OR
( ...|... )
Capturing group
\1
Contents of Group 1
\2
Contents of Group 2