How to use the regex cheatsheet
- Type a word in Filter to search the table: a token name (
lookahead), a group (flags,replace) or a goal (phone,email,date). Leave it empty to see all 57 entries. - Put a pattern in Try a pattern. The default is
\b\d{3}-\d{4}\b. - Set Flags (up to 8 characters, any of
d g i m s u v y). - Paste sample input into Test text. The match table, capture groups and a highlighted copy of the text appear above the cheatsheet.
What it does and when to use it
Use it when you know roughly what you want but not the exact syntax, such as how to write a lookbehind or which replacement code inserts a named group. You can then prove the pattern on real data before it goes into code. The table has nine groups: characters, classes, anchors, quantifiers, groups, lookaround, flags, replacement codes ($1, $<name>, $&, $$) and eight common patterns (ISO date, hex colour, URL slug, E.164 phone number and more).
The live tester is deliberately small. For replace previews and a token-by-token explanation of your pattern, use the advanced regex tester. To put user input inside a pattern safely, escape it first with the regex escaper or the string escaper.
How it works
Your pattern is compiled with new RegExp(pattern, flags) in your browser. Unknown flags, repeated flags and the u + v combination are rejected with a clear message before compiling. With g or y, every match is listed (up to 1,000). Without them, only the first is. Each row shows the match index and every capture group. The filter keeps a cheatsheet row only when all your words appear in it. Nothing leaves your device.
Worked examples
A lookbehind that grabs amounts after a dollar sign. Pattern (?<=\$)\d+, flags g, text Total $45, tax $5:
Matches: 2
# | Index | Match
1 | 7 | 45
2 | 16 | 5
A back-reference pasted as a literal, /(\w)\1/g, on hello balloon finds doubled letters:
Matches: 3
Capture groups: 1
1 | 2 | ll | l
2 | 8 | ll | l
3 | 10 | oo | o
Filtering for lookbehind returns Showing: 2 of 57 entries: (?<=…) and its negative form (?<!…).
Limits and tips
- Engine differences. Lookbehind and named groups work in current browsers and Node, but older engines may reject them.
- Long input can freeze the page. The tester runs on the main thread, so a catastrophic pattern on a long text can lock the tab.
- Anchors need m for lines.
^and$match the whole text’s start and end unless you addm. - Common patterns are starting points. They check the format, not meaning:
^\d{4}-\d{2}-\d{2}$accepts2026-13-45.
Frequently asked questions
Which regex flavour does this follow?
Can I paste a pattern written as /…/flags?
Why does my pattern only find one match?
Is the email pattern good enough to validate addresses?
What does the warning about nested quantifiers mean?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.