^
Start of string/line
^Hello
$
End of string/line
world$
\b
Word boundary
\bword\b
\B
Non-word boundary
\Bword\B
\A
Start of string (no multiline)
\AStart
\Z
End of string (no multiline)
End\Z
.
Any character except newline
a.b
\d
Digit [0-9]
\d{3}
\D
Non-digit [^0-9]
\D+
\w
Word character [a-zA-Z0-9_]
\w+
\W
Non-word character
\W
\s
Whitespace [ \t\n\r\f\v]
\s+
\S
Non-whitespace
\S+
[abc]
Character set (a, b, or c)
[aeiou]
[^abc]
Negated set (not a, b, or c)
[^0-9]
[a-z]
Character range
[a-zA-Z]
*
Zero or more
ab*c
+
One or more
ab+c
?
Zero or one (optional)
colou?r
{n}
Exactly n times
\d{4}
{n,}
n or more times
\w{3,}
{n,m}
Between n and m times
\d{2,4}
*?
Zero or more (lazy)
<.*?>
+?
One or more (lazy)
\w+?
??
Zero or one (lazy)
colou??r
*+
Zero or more (possessive)
\w*+
(abc)
Capturing group
(\d{3})-(\d{4})
(?:abc)
Non-capturing group
(?:https?://)
(?<name>abc)
Named capturing group
(?<year>\d{4})
\1
Backreference to group 1
(\w+)\s\1
a|b
Alternation (a or b)
cat|dog
(?=abc)
Positive lookahead
\d(?=px)
(?!abc)
Negative lookahead
\d(?!px)
(?<=abc)
Positive lookbehind
(?<=\$)\d+
(?<!abc)
Negative lookbehind
(?<!\$)\d+
g
Global - match all occurrences
/pattern/g
i
Case-insensitive matching
/hello/i
m
Multiline - ^ and $ match line boundaries
/^line/m
s
Dotall - . matches newlines
/a.b/s
u
Unicode - enable Unicode matching
/\p{L}/u
y
Sticky - match at lastIndex position
/pattern/y
Email
Basic email validation
[\w.-]+@[\w.-]+\.\w{2,}
URL
Basic URL matching
https?://[\w.-]+(?:/[\w.-]*)*
IPv4
IPv4 address
\b\d{1,3}(\.\d{1,3}){3}\b
Phone
US phone number
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
Date
Date (YYYY-MM-DD)
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
Hex Color
Hex color code
#(?:[0-9a-fA-F]{3}){1,2}\b
browserutils
Regex Cheatsheet