Tool
JavaScript regex tester — match, capture and replace
Debug your own JavaScript regular expression: live match highlighting, numbered and named capture groups with offsets, replace-template preview, and JSON/CSV export — a worker enforces a time limit so catastrophic backtracking can't freeze the page.
Expression
Processing: matching and replacement run entirely in this browser tab — your expression and text are never sent, stored or written into links. Closing the tab discards them.
Matches
Highlighted textThe expression ran but found no matches in this text.
| # | Position | Match | Capture groups |
|---|
Replace
How this differs from the redaction tool
The log redaction tool runs a fixed rule set — you paste text, it flags and replaces known credential shapes. This playground is for debugging your own expression: type any JavaScript regex, toggle its flags, and see exactly what it matches, which capture groups it produces (numbered and named, with start/end offsets), and what a replacement template would output.
Semantics are the browser's own: matching runs the real RegExp engine in a Web Worker, so results match what your code will do — including the difference between g on and off, sticky y anchoring and u code-point behavior. Replacement goes through String.prototype.replace, so $1, $<name>, $&, $$, $` and $' all work exactly like in your app. If an expression enters catastrophic backtracking, the worker is killed after 1.5 seconds and the page stays responsive.
FAQ
Which regex flavor does this use?
Exactly the JavaScript engine in your browser — the same RegExp your code would run. Flags g, i, m, s, u, y and d are supported; lookbehind, named groups and Unicode sets work wherever the browser supports them.
Why does the page say 'possible catastrophic backtracking'?
Matching runs in a Web Worker with a 1.5-second limit. Nested quantifiers like (a+)+ or overlapping alternations can explode exponentially on the wrong input — when the limit is hit the worker is terminated and the page stays responsive. Simplify the expression or shorten the text and try again.
What replacement syntax works?
The native String.prototype.replace substitutions: $1…$99 for numbered groups, $<name> for named groups, $& for the whole match, $` and $' for the text before/after, and $$ for a literal dollar sign.
Why do results differ when I uncheck g?
Without the global flag JavaScript only reports the first match — String.replace also replaces just that one. The match list, highlight and replace preview all follow that, so what you see is exactly what your code will do.
Is my text uploaded or stored?
No. Compiling, matching and replacing all run inside this browser tab — nothing is sent to any server, stored, or written into a URL. Closing the tab discards it.