tokens · anchors · quantifiers · groups · flags

Complete regex cheatsheet

Searchable reference of every regex token — character classes, anchors, quantifiers, groups, lookarounds, and flags. Click any token to copy.

Regex Cheatsheet
Sections
5
categories
Tokens
44
total
Visible
44
all
Size
1.3 KB
reference
Filter
tokens · regex
Character classes
.
\d
\D
\w
\W
\s
\S
[abc]
[^abc]
[a-z]
\p{L}
Anchors
^
$
\b
\B
\A
\Z
Quantifiers
*
+
?
{n}
{n,}
{n,m}
*?
+?
??
*+
Groups & lookarounds
(...)
(?:...)
(?<name>...)
\1
\k<name>
(?=...)
(?!...)
(?<=...)
(?<!...)
|
Flags
g
i
m
s
u
y
d
meaning · description
Character classes
Any character (except newline unless s flag)
a.c → abc, axc
Digit [0-9]
\d+ → 42
Non-digit [^0-9]
Word char [A-Za-z0-9_]
Non-word char
Whitespace [ \t\n\r\f\v]
Non-whitespace
Any of a, b, c
Anything except a, b, c
Range a through z
Unicode letter (needs u flag)
Anchors
Start of string (or line with m flag)
End of string (or line with m flag)
Word boundary
Non-word boundary
Start of input (PCRE/Python; not JS)
End of input (PCRE/Python; not JS)
Quantifiers
0 or more, greedy
1 or more, greedy
0 or 1, greedy
Exactly n times
n or more times
n to m times
0 or more, lazy
1 or more, lazy
0 or 1, lazy
Possessive (no backtrack — not in JS)
Groups & lookarounds
Capturing group
Non-capturing group
Named capturing group
Backreference to group 1
Backreference to named group
Positive lookahead
Negative lookahead
Positive lookbehind
Negative lookbehind
Alternation
Flags
global — Find all matches, not just the first.
ignoreCase — Case-insensitive matching.
multiline — ^ and $ match at each line boundary.
dotAll — Dot . matches newlines too.
unicode — Treat pattern as Unicode; enable \p{...} properties.
sticky — Match only from lastIndex (no scanning ahead).
indices — Result includes per-group start/end indices.
Quick Start

How to use the cheatsheet

Five sections cover every JS regex token. Filter, then click Copy to grab the syntax.

  1. 01

    Browse sections

    Five panels group every JavaScript regex token by purpose: character classes, anchors, quantifiers, groups & lookarounds, and flags. The structure mirrors the ECMAScript spec hierarchy so it maps 1:1 to MDN’s regex reference and to the PCRE manual for cross-flavour work.

    The first three sections are positional or quantitative; the last two add control — lookahead, lookbehind, and flag-level behaviour like u (Unicode) or s (dotAll).

    metacharactersanchorsquantifierslookaheadMDN-aligned
    sections · ECMAScript order5 panels · 80+ tokens
    Character classes
    Anchors
    Quantifiers
    Groups & lookarounds
    Flags
    indexed · ECMA-262PCRE-compatible
  2. 02

    Filter live

    Type a token like \b (word boundary), a meaning like boundary, or even part of an example. The filter runs through a memoised useMemo across token name, meaning, and example fields, so partial matches surface deep tokens instantly.

    Try (?= to jump straight to lookahead, or (?<= for lookbehind — both ES2018+ features supported in every evergreen browser.

    live searchuseMemolookaheadlookbehindanchors
    query · cross-field filter\b · 2 matches
    Filter: boundary
    → \b  word boundary
    → \B  non-word boundary
    narrowed · indexedinstant · client-side
  3. 03

    Copy a token

    Click Copy on any row to grab that exact escape — backslashes preserved — through navigator.clipboard.writeText. Paste straight into your editor, a test fixture, or a tab on the Regex Tester without re-typing escapes.

    Useful for tricky metacharacters like \p{L} (any letter) or anchors like \A / \Z where one stray backslash silently changes the pattern.

    clipboardmetacharactersescapesfixturesinstant
    row · copied\b · clipboard
    ✓ Copied \b
    2 chars · 1 tokennavigator.clipboard
  4. 04

    Copy all

    Hit Copy all to grab the entire cheatsheet as a tab-separated reference — token, meaning, and example per row. Paste into Notion, Excel, or a Markdown table and the column alignment survives.

    Everything runs client-side: the static dataset ships with the page, the filter is in-memory, and clipboard writes never touch a server.

    TSVbulk exportNotionMarkdown tableprivacy-first
    export · TSV bundle80+ rows · saved
    ✓ Copied cheatsheet (TSV)
    ready to ship0 outbound
Pro tips

Regex patterns that don't melt down

Use named groups

(?<year>\d{4}) reads better than $1 and survives reordering. Supported in ECMAScript 2018+.

Anchor strictly

Use ^/$ with the m flag when matching whole lines. Without anchors, partial matches sneak through.

Avoid catastrophic backtracking

Nested quantifiers like (a+)+ can explode. Run patterns through ReDoS Detector first.

Escape every literal

Backslash any meta character you want literally: \.\$\^\*\+\?\(\)\[\]\{\}\|\\.

Test edge cases

Empty string, single character, unicode, the maximum length you expect — write fixtures for each.

Patterns aren&rsquo;t parsers

Don’t parse HTML, JSON, or balanced parens with regex. Use a proper parser when the grammar is recursive.

Use Cases

When to reach for the cheatsheet

Developers, writers, students.

Quick lookup

Forgot \b vs \B? Open the cheatsheet. Compiles through the JavaScript RegExp constructor — engine quirks (Unicode property escapes, sticky matching, named groups) work when their flags are on. Error messages cite the exact position of any syntax issue.

ReDoS-safe

Learn syntax

One-page overview of every token. Pairs with the ReDoS detector to catch catastrophic backtracking before you deploy. A pattern that handles 1k-character input fine can become a denial-of-service vector on attacker-controlled 1M-character input.

ECMA-compliant

PR review

Pin as a tab while reviewing regex changes. Output exports as JavaScript, Python re, Java util.regex, .NET System.Text.RegularExpressions, PCRE, and POSIX — language quirks are highlighted on conversion so you don't ship a JS-only pattern to a Go service.

spec-grade

Code authoring

Search for the exact escape you need. Capture groups (named or numbered) round-trip cleanly into replacement strings, JSON output, or CSV extraction without re-typing. Backreferences ($1, ${name}) preserve semantics across languages.

cross-engine

Live demos

Project the cheatsheet alongside the tester. Test against edge cases — empty input, single character, max length, multibyte boundaries — to catch off-by-one and zero-length match bugs before they reach production.

test-ready

Cross-flavour

Spot which tokens have caveats elsewhere. All matching runs client-side so secret patterns never leave the browser. Useful when the pattern itself is sensitive (PII regexes, internal data formats, security filters).

production-ready
FAQ

Frequently asked questions

JavaScript first — but anchors, classes, and quantifiers are the same across most engines. See the Flavour Matrix for portability.
In the Groups & lookarounds section: (?=...), (?!...), (?<=...), (?<!...).
Common tokens have inline examples; the rarer ones link out to the tester to try them live.
Copy all grabs the entire cheatsheet — paste then trim. Or copy tokens one at a time.
No. The cheatsheet is static and renders entirely in your browser.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!