Regex Cheatsheet
Searchable reference of regular expression syntax: character classes, anchors, quantifiers, groups, lookaround, and flags.
. | Any character except line breaks (unless the s flag is set). |
\d | Any digit, equivalent to [0-9].\d{3} → 123 |
\D | Any non-digit character. |
\w | Any word character: letters, digits, underscore. |
\W | Any non-word character. |
\s | Any whitespace (space, tab, newline). |
\S | Any non-whitespace character. |
[abc] | Any one of a, b, or c. |
[^abc] | Any character except a, b, or c. |
[a-z] | Any character in the range a to z. |
^ | Start of string (or line, with the m flag). |
$ | End of string (or line, with the m flag). |
\b | Word boundary between a word and non-word character.\bcat\b |
\B | Not a word boundary. |
* | Zero or more of the preceding token (greedy). |
+ | One or more of the preceding token (greedy). |
? | Zero or one of the preceding token (optional). |
{n} | Exactly n of the preceding token.a{3} → aaa |
{n,} | n or more of the preceding token. |
{n,m} | Between n and m of the preceding token. |
*? | Lazy quantifier — match as few as possible. |
(abc) | Capturing group; remembers the match for back-references. |
(?:abc) | Non-capturing group; groups without storing the match. |
(?<name>abc) | Named capturing group, accessible as match.groups.name. |
a|b | Alternation — match a or b. |
\1 | Back-reference to the first captured group. |
(?=abc) | Positive lookahead — followed by abc. |
(?!abc) | Negative lookahead — not followed by abc. |
(?<=abc) | Positive lookbehind — preceded by abc. |
(?<!abc) | Negative lookbehind — not preceded by abc. |
g | Global — find all matches, not just the first. |
i | Case-insensitive matching. |
m | Multiline — ^ and $ match line starts/ends. |
s | Dotall — . matches newline characters too. |
u | Unicode mode — full Unicode and \p{} support. |
y | Sticky — match starting exactly at lastIndex. |
\. | A literal dot (escapes the special meaning). |
\n | A newline character. |
\t | A tab character. |
\\ | A literal backslash. |
Syntax shown is JavaScript (ECMAScript) regex. Test patterns live with the Regex Tester tool.
About Regex Cheatsheet
A searchable reference of JavaScript regular expression syntax — character classes, anchors, quantifiers, groups, lookaround assertions, flags, and escapes — each with a plain-English explanation and example. Search by token or description, or filter by category. Pair it with the Regex Tester to try patterns live.
All processing happens entirely in your browser using modern web APIs. Nothing is uploaded to our servers — your data stays local and private. Free to use forever.
Common use cases
- Remembering the syntax for lookahead, lookbehind, or named groups
- Looking up what a token like \b or *? means
- Learning regex with categorized, explained examples
- Checking which flag enables multiline or dotall behavior
- Quickly referencing quantifier syntax while writing a pattern
How it works
A curated set of regex tokens, each labeled with a category and description (and an example where helpful), is filtered client-side. Search matches the token and its explanation; category buttons narrow to a group such as Quantifiers or Lookaround. The syntax shown is JavaScript (ECMAScript) regex.