Regex Tester
Test a JavaScript regular expression locally. Groups, positions, and a replacement preview.
Added 2026-10-24
What it does
This page checks a JavaScript regular expression online. A pattern is valid when the language accepts it, and the matches are what it finds in the text. Regex Tester runs a JavaScript regular expression against text you paste. With the g flag it lists every match. Each group shows its text and the start and end positions. Replace previews String.prototype.replace, including $1 and named groups such as $<name>. The search runs in a worker and stops after one second, so a nested quantifier such as (a+)+ against a long run of the letter a does not freeze the tab. A fresh worker starts after that stop. Unicode mode u and Unicode sets v cannot be combined. An empty match, such as a*, advances one character, or one code point in Unicode mode, so the search cannot sit on the same index. The page does not test Python, PCRE, or a database dialect.
How to use it
- Enter a JavaScript pattern and the text. The page checks that the pattern is valid. Turn on g to list every match.
- Each group shows its text and the start and end positions.
- Turn on Replace to preview String.replace, including $1 and $<name>.
- The search runs in a worker and stops after one second.
Common mistakes
- Nested quantifiers can backtrack forever. A pattern such as (a+)+ against a long run of a's may never finish. This page stops the search after one second and starts a fresh worker.
- u and v cannot be combined. Unicode mode and Unicode sets are different flags. Pick one.
- An empty match is not a dead loop. A pattern such as a* can match an empty string. The search moves forward one character, or one code point in Unicode mode, so it cannot stay on the same spot.
The pattern and the text stay in this tab. A slow pattern is stopped after one second, and nothing is uploaded.
Related guides
- Check a JavaScript regular expression
A valid JavaScript pattern can still match the wrong text. Flags, groups, replacement, and the one-second stop.