Regex Cheat Sheet

Regular Expressions syntax reference for pattern matching.

Character Classes

.Any character except newline
\wWord character (a-z, A-Z, 0-9, _)
\dDigit (0-9)
\sWhitespace (space, tab, newline)
[abc]Any of a, b, or c
[^abc]Not a, b, or c
[a-z]Character between a and z

Quantifiers

*0 or more
+1 or more
?0 or 1
{3}Exactly 3
{3,}3 or more
{3,5}Between 3 and 5

Anchors

^Start of string/line
$End of string/line
\bWord boundary

Groups & Lookaround

(...)Capturing group
(?:...)Non-capturing group
(?=...)Positive lookahead
(?!...)Negative lookahead