Show Menu

RegExp Cheat Sheet (DRAFT) by

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

Character Classes

any of these characters (a or b or c)
not any of these characters (not a or b or c)
any characters in the range (a through c)
not any characters in this range (not a through c)
X or Y

Predefined Character Classes

any character
a digit: [0-9]
a non-digit: [^0-9]
a whitespace character: " " (space), \r (the carriage return), \n (newline), \t (tab), and \f (the form feed)
a non-wh­ite­space character: [^\s]
a word character: [a-zA-­Z0-9_]
a non-word character: [^\w]


the beginning of the line
the end of the line
a word boundary
a non-word boundary
boundaries - do not select any characters but sets pattern to some edge


0 or more repiti­tions of X
1 or more repiti­tions of X
0 or 1 instance of X
exactly m instances of X
X{m, }
at least m instances of X
between m and n (inclu­sive) instances of X
use ( . . . ) parent­hesis to group things you want to find repeti­tions of

Groups & References

( . . . )
define­s/c­aptures a group
contents of group 1
contents of group 2
replace with group 1
replace with group 2
ex: .replace( / regExp /, $2)
{replaces regular expres­sions with group 2}


special characters to be escaped with \