Regex Cheatsheet
Character Classes
[abc]β Any of a, b, or c[^abc]β Not a, b, or c[a-z]β Any lowercase letter[A-Za-z]β Any letter\dβ Digit [0-9]\Dβ Non-digit\wβ Word character [a-zA-Z0-9_]\Wβ Non-word character\sβ Whitespace\Sβ Non-whitespace.β Any character
Quantifiers
*β 0 or more+β 1 or more?β 0 or 1{n}β Exactly n{n,}β n or more{n,m}β Between n and m
Anchors
^β Start of string$β End of string\bβ Word boundary\Bβ Non-word boundary
Groups
(abc)β Capturing group(?:abc)β Non-capturing group(?=abc)β Lookahead(?!abc)β Negative lookahead
Escaping
Escape these special chars:. * + ? ^ $ { } [ ] ( ) | \
Save this page and use our Regex Tester for practice!