Regex Cheat Sheet

Character Class
. any character
\w \d \s  word, digit, whitespace
\W \D \S not word, digit, whitespace
[abc] any of a, b or c
[^abc] not a, b or c
[a-z] character between a to z
 
Anchors
^abc$ start / end of line
\b word boundry
 
Escape characters
\. \* \\ escaped special characters
\t \n \r tab, linefeed, carriage return
\u00A9 unicode escaped ©
 
Quantifiers and alternation
a* a+ a? zero or 1, 1 or more, zero or 1
a{5} a{2,} exactly five, two or more
a{1,3} between one & three
ab|cd match ab or cd
 
Groups
(abc) capture group
\1 backreference to group #1