Regex Cheatsheet
A printable reference of JavaScript regex syntax — character classes, quantifiers, groups, lookarounds, flags.
Quick answer: A printable reference of JavaScript regex syntax — character classes, quantifiers, groups, lookarounds, flags.
Last updated
Frequently asked questions
- What's on the cheatsheet?
- Character classes, anchors, quantifiers, groups, alternation, lookarounds, JS flags and a few useful patterns — all in one screen.
- Which regex flavour does this cover?
- Modern JavaScript / ECMAScript regex. Most rules also apply to Perl, Python and PCRE-flavoured regex.
- What does \d mean?
- A digit (0–9). \D is the inverse — any non-digit. They're shorthand for [0-9] and [^0-9].
- What's the difference between * and +?
- * matches zero or more; + matches one or more. Both are greedy unless followed by ?.
- What is a lookahead?
- A zero-width assertion that peeks ahead without consuming characters. (?=…) requires the pattern to follow; (?!…) requires it NOT to follow.
- Are named groups supported?
- Yes — (?<name>…) in modern JS engines (ES2018+). Older runtimes may need a transform.
- What does the g flag do?
- Tells the regex engine to find every match, not just the first. Required by replaceAll() and matchAll().
- Can I print this cheatsheet?
- Yes — use your browser's print menu (Ctrl/Cmd+P). It's laid out as a single page reference.
- Where do I test patterns?
- Use our Regex Tester — paste a pattern and a sample, see matches and groups highlighted.
- Is this cheatsheet free?
- Yes — free, no signup.