Regex Tester (JavaScript)
Test JavaScript regular expressions live: highlighted matches, capture groups, named groups and replace preview. Runs in a sandboxed worker, so a runaway pattern cannot freeze the page.
/ /g
Examples:
Matches
Showing the first 1,000 matches.
Result
How to Use
- 01 Write the pattern Type the pattern without slashes and toggle flags like g (all matches), i (ignore case) or m (multiline).
- 02 Paste test text Matches are highlighted and listed with their position and capture groups.
- 03 Try a replacement Use $1, $2 or $<name> in the replacement to see the result of String.replace().
About this tool
Regular expressions describe text patterns. They are great for validation and search-and-replace, but hard to read. Test them against real examples, including the cases that should not match.
Frequently Asked Questions
JavaScript (ECMAScript) as implemented by your browser, including lookbehind, named groups and Unicode property escapes like \p{L} with the u flag. Patterns from PCRE, Python or Java mostly work but differ in details.
Some patterns, like (a+)+$, take exponential time on certain input (catastrophic backtracking). The test runs in a worker and is stopped after one second, which is also a warning sign for using that pattern in production.