Regex Tester
Type a pattern and some text to see every match highlighted, with numbered and named capture groups, plus a live replace preview. Everything runs in your browser.
Highlighted text
Matches
Replace preview
How the tester runs your pattern
Your pattern is compiled with new RegExp(pattern, flags) — the same engine your JavaScript runs. To list every match the tester iterates with the global flag on internally, even if you leftg unticked; your flags are still what drive thereplace preview, so without g only the first match is substituted. A bad pattern never crashes the page: the engine's error message is shown and the last good highlight stays put. The test text is capped at 100,000 characters and the match list at 10,000 entries.
Capture groups
( … ) captures a numbered group; (?<name> … )captures a named one (it still takes a number too). Use(?: … ) when you only need grouping, not capture. In the replacement string, $1 pastes group 1 and$<name> pastes a named group;$& is the whole match and $$ is a literal dollar.
Worked example
Pattern (\w+)@(?<domain>[\w.]+) againstalice@example.com matches the whole address, capturesalice as group 1 and example.com asdomain. Replacement $1 [at] $<domain>rewrites it to alice [at] example.com — a quick way to de-link emails in bulk text.
Cheat sheet
| Token | Matches |
|---|---|
^ $ | start / end of string (or line with m) |
\b \B | word boundary / non-boundary |
. | any char except newline (any char with s) |
\d \w \s | digit / word char / whitespace (capitals negate) |
[abc] [^abc] [a-z] | character class / negated / range |
* + ? | 0+, 1+, 0 or 1 — add ? for lazy |
{n} {n,} {n,m} | exactly n / n or more / n to m |
(a|b) | alternation |
( ) (?: ) (?<n> ) | capture / non-capture / named |
(?= ) (?! ) | lookahead / negative lookahead |
(?<= ) (?<! ) | lookbehind / negative lookbehind |
\1 \k<n> | back-reference to a numbered / named group |
| flags | g all, i case, m multiline, s dotall, u unicode, y sticky |
Building a pattern for URLs or slugs? Pair this with theURL encoder, thecase converter or theword counter.
Related tools
Frequently asked questions
Which regex flavour is this?
What do the flags do?
Why is g always effectively on for the match list?
How do I reference a group in the replacement?
Is there a size limit?
My pattern says 'Invalid regular expression' — why?
Does a zero-width match break anything?
Is my text uploaded?
Last reviewed: September 2026. Figures and formulas are checked against their published sources; see the site's data notes.