Regex cheatsheet

Try any of these live in the regex tester.

.
Any character except newline.
\d
A digit (0-9). \D for non-digit.
\w
A word character (letter, digit, underscore). \W for the opposite.
\s
A whitespace character. \S for non-whitespace.
^
Start of the string (or line, in multiline mode).
$
End of the string (or line, in multiline mode).
*
Zero or more of the preceding element.
+
One or more of the preceding element.
?
Zero or one of the preceding element (also makes quantifiers lazy).
{n}
Exactly n repetitions.
{n,m}
Between n and m repetitions.
[abc]
Any one of a, b, or c.
[^abc]
Any character except a, b, or c.
[a-z]
Any lowercase letter (range).
(abc)
A capturing group.
(?:abc)
A non-capturing group.
(?<name>abc)
A named capturing group.
a|b
Match a or b.
\b
A word boundary.
(?=abc)
Positive lookahead — matches if followed by abc, without consuming it.
(?!abc)
Negative lookahead — matches if NOT followed by abc.
(?<=abc)
Positive lookbehind — matches if preceded by abc.
(?<!abc)
Negative lookbehind — matches if NOT preceded by abc.
i flag
Case-insensitive matching.
g flag
Global — find all matches, not just the first.
m flag
Multiline — ^ and $ match at line breaks, not just string start/end.
^[\w.-]+@[\w.-]+\.\w+$
A simple email pattern.
^https?://[\w.-]+
Matches an http/https URL start.
^\d{3}-\d{3}-\d{4}$
A US-style phone number, e.g. 555-123-4567.

What is Regex cheatsheet?

A quick reference for regular expression syntax — character classes, quantifiers, groups, lookaheads — the pieces that are easy to forget between uses.

How to use it

Search by symbol or keyword; try any pattern live afterward in the regex tester.

Example

Searching "lookahead" surfaces (?=abc) positive lookahead and (?!abc) negative lookahead.