Regex Cheatsheet

LOCAL · IN-BROWSER

Searchable reference of regular expression syntax: character classes, anchors, quantifiers, groups, lookaround, and flags.

Advertisement728 × 90
Your ad could be here
.Any character except line breaks (unless the s flag is set).
\dAny digit, equivalent to [0-9].\d{3} → 123
\DAny non-digit character.
\wAny word character: letters, digits, underscore.
\WAny non-word character.
\sAny whitespace (space, tab, newline).
\SAny 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).
\bWord boundary between a word and non-word character.\bcat\b
\BNot 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|bAlternation — match a or b.
\1Back-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.
gGlobal — find all matches, not just the first.
iCase-insensitive matching.
mMultiline — ^ and $ match line starts/ends.
sDotall — . matches newline characters too.
uUnicode mode — full Unicode and \p{} support.
ySticky — match starting exactly at lastIndex.
\.A literal dot (escapes the special meaning).
\nA newline character.
\tA tab character.
\\A literal backslash.

Syntax shown is JavaScript (ECMAScript) regex. Test patterns live with the Regex Tester tool.

Advertisement728 × 90
Your ad could be here

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.