</>

Regex Cheatsheet

Search and filter through regular expression syntax tokens, modifiers, qualifiers, and capture assertions.

Matches any single character except newlineCharacter Classes
Example: a.c matches abc, a2c
.
Matches any digit (equivalent to [0-9])Character Classes
Example: \d matches 5, 8
\d
Matches any non-digit (equivalent to [^0-9])Character Classes
Example: \D matches a, !
\D
Matches word character (alphanumeric + underscore)Character Classes
Example: \w matches x, 3, _
\w
Matches any non-word characterCharacter Classes
Example: \W matches %, space, -
\W
Matches any whitespace character (space, tab, newline)Character Classes
Example: \s matches tab, space
\s
Matches any non-whitespace characterCharacter Classes
Example: \S matches x, 4, #
\S
Asserts position at the start of the stringAnchors
Example: ^abc matches only starting with abc
^
Asserts position at the end of the stringAnchors
Example: abc$ matches ending with abc
$
Asserts a word boundary positionAnchors
Example: \bcat\b matches cat but not catalog
\b
Matches 0 or more occurrences of preceding tokenQuantifiers
Example: a* matches '', a, aaa
*
Matches 1 or more occurrences of preceding tokenQuantifiers
Example: a+ matches a, aaa
+
Matches 0 or 1 occurrence of preceding token (optional)Quantifiers
Example: colou?r matches color, colour
?
Matches exactly n occurrences of preceding tokenQuantifiers
Example: a{3} matches aaa
{n}
Matches n or more occurrences of preceding tokenQuantifiers
Example: a{2,} matches aa, aaa, aaaa
{n,}
Matches between n and m occurrences of preceding tokenQuantifiers
Example: a{2,4} matches aa, aaa, aaaa
{n,m}
Capturing group for sub-expressions and extractionGroups
Example: (abc) matches abc and creates group
(...)
Non-capturing group (matches but doesn't extract)Groups
Example: (?:abc) matches abc without group index
(?:...)
Positive lookahead assertionLookarounds
Example: a(?=b) matches a only if followed by b
(?=...)
Negative lookahead assertionLookarounds
Example: a(?!b) matches a only if not followed by b
(?!...)

Frequently Asked Questions

What is this cheatsheet for?
It serves as a fast, searchable reference card for writing and understanding regex tokens and operators.
Can I copy patterns?
Yes, click copy next to any token pattern to put it directly on your clipboard.