Regex Tester (JavaScript)
Write a regular expression and see every match highlighted as you type, with capture groups, named groups and a live replace preview — using your browser's real JavaScript regex engine.
Runs in your browser — nothing is uploaded Free, no limits
Pattern
Test string
Matches highlighted
Released 2026-10-09, patched 2026-11-23. Not a date: 2026-13-01
Replace
The text with replacements applied appears here.Regex quick reference (JavaScript)
Characters
- .
- any char except line breaks
- \d \D
- digit / not digit
- \w \W
- word char [A-Za-z0-9_] / not
- \s \S
- whitespace / not
- \p{L}
- any letter (needs u flag)
- \t \n
- tab / line feed
Sets & anchors
- [abc]
- a, b or c
- [^abc]
- not a, b or c
- [a-z]
- range
- ^ $
- start / end (of line with m)
- \b \B
- word boundary / not
Quantifiers
- * + ?
- 0+, 1+, 0 or 1
- {3} {2,} {2,5}
- exactly, at least, between
- *? +?
- lazy (as few as possible)
Groups
- (abc)
- capture group → $1
- (?<name>abc)
- named group → $<name>
- (?:abc)
- non-capturing group
- \1 \k<name>
- backreference
- a|b
- a or b
Lookaround
- (?=abc)
- followed by
- (?!abc)
- not followed by
- (?<=abc)
- preceded by
- (?<!abc)
- not preceded by
Replacement
- $1 $2
- numbered group
- $<name>
- named group
- $&
- whole match
- $` $'
- text before / after match
- $$
- a literal $
How to use the Regex Tester
- Type your pattern between the slashes, or load an example such as Email or Date.
- Turn flags on or off — g finds all matches, i ignores case, m makes ^ and $ work per line.
- Paste your test text and check the highlighted matches and the group table.
- Enter a replacement using $1 or $<name> to preview the replaced text, then copy it.
Frequently asked questions
Which regex flavor does this tester use?
It uses the JavaScript (ECMAScript) engine built into your browser, so results match what new RegExp() and String.prototype.replace do in Chrome, Firefox, Safari and Node.js. Other flavors like PCRE or Python differ in places — for example, possessive quantifiers and atomic groups aren't supported in JavaScript.
Why does my regex only find one match?
Without the g (global) flag, JavaScript stops after the first match. Turn on g to find every match and to make replace change all occurrences.
How do I use capture groups in the replacement?
Use $1, $2 and so on for numbered groups, $<name> for named groups like (?<year>\d{4}), $& for the whole match and $$ for a literal dollar sign.
What does "pattern took too long" mean?
Some patterns, such as (a+)+ or (.*)*, can take exponential time on text that almost matches — this is called catastrophic backtracking. The tester runs your regex in a background worker and stops it after 1.5 seconds so the page never freezes; rewrite the nested quantifier to fix it.
What's the difference between the m and s flags?
m (multiline) makes ^ and $ match at the start and end of every line. s (dotAll) makes . match line breaks too. They're independent and are often used together.
Is my test data sent anywhere?
No. Matching runs locally in your browser, so logs and other private text never leave your device.