Preview a regular expression replacement, with every match listed so you can check it before running it for real.
Regex Tester
Test a regular expression against a subject, with every match, its position, and its numbered and named capture groups.
- Free
- No sign-up
- Runs in your browser
Input
JavaScript regular expression syntax, without the surrounding slashes.
0 characters
Processed entirely in your browser. Nothing is uploaded.
s dot matches newline, u unicode mode. The g flag is always applied.
Try an example
Fill in Pattern and Test string to continue.
Enter your input to see the result
Everything happens on this device. No upload, no account, no network request.
How to use this tool
- 1
Enter a pattern and the text to search.
- 2
Every match is listed with its position and capture groups, so you can see exactly what the pattern is doing.
- 3
A pattern that could match the empty string is refused with an explanation, because it would match at every position.
Questions about Regex Tester
Which regex flavour is this?
The JavaScript engine built into your browser - the same one your code will run. It supports lookahead, lookbehind, named groups and Unicode property escapes, but it is not PCRE: no recursion, no atomic groups, no possessive quantifiers. A pattern copied from a Perl or PHP answer may need adjusting.
What is catastrophic backtracking, and will you warn me?
Nested quantifiers such as `(a+)+b` can take exponential time on a subject that nearly matches - a real denial-of-service vector if the pattern runs on user input. The tool warns when it spots that shape, and caps the match count. It cannot detect every case: deciding whether a pattern is pathological is undecidable in general.
Is my data sent anywhere?
No. This tool runs as JavaScript inside your browser tab. There is no network request carrying your input, nothing is written to a server log, and it keeps working with your connection switched off. You can confirm it in the browser’s network panel. That matters more here than elsewhere on the site: developer tools handle tokens, keys and production data.
Does the Regex Tester work offline?
Yes. Once the page has loaded it runs entirely as JavaScript on your own device, so the Regex Tester keeps working with the network switched off and nothing is ever sent to a server.
Is anything I enter into the Regex Tester uploaded or stored?
No. The Regex Tester runs in your browser, so whatever you type or paste never leaves your device — there is no server round-trip, nothing is logged, and there is nothing to delete afterwards.
Related tools
Other tools you might reach for next.
A reference table of JavaScript regular expression syntax, grouped by purpose, with an example for every token.
Format and indent JSON, with optional alphabetical key sorting and a precise syntax error when it will not parse.
Strip every byte of insignificant whitespace from JSON and report the saving.
Check that JSON is syntactically valid, report its structure, and flag duplicate keys that JSON.parse accepts silently.
Compare two JSON documents structurally, by path, distinguishing a type change from a value change.
Evaluate a JSONPath expression against a document and see every match with the path that produced it.
Escape text so it can be embedded as a JSON string value, handling control characters and astral code points.