Regex Cheatsheet
Regular expression syntax, patterns, and common examples.
Basic Patterns
.Any character except newline
^Start of string
$End of string
\dAny digit [0-9]
\DAny non-digit
\wAny word character [a-zA-Z0-9_]
\WAny non-word character
\sAny whitespace character
\SAny non-whitespace character
Quantifiers
*Zero or more times
+One or more times
?Zero or one time
{n}Exactly n times
{n,}At least n times
{n,m}Between n and m times
Character Classes
[abc]Any of a, b, or c
[^abc]Not a, b, or c
[a-z]Any lowercase letter
[A-Z]Any uppercase letter
[0-9]Any digit
Groups & Lookaround
(abc)Capture group
(?:abc)Non-capturing group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind