Regex tester (JavaScript)
Type a pattern, flags and some text to see the matches right away. It runs the same RegExp engine your JavaScript code uses.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter pattern, flags (g i m s u y d v), test text, apply replace and replacement.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
The tool builds new RegExp(pattern, flags). With the g flag it collects every match with matchAll; without it, only the first match via exec. Replace uses String.replace and supports $1 and $<name>.
Example
Inputs: Pattern = (\d{4})-(\d{2})-(\d{2}), Flags (g i m s u y d v) = g, Apply replace = no, Replacement = #. Result: Matches: 2; Result: Match found.
Limits and caveats
- JavaScript flavor only: some PCRE or Python features such as inline (?i) are not supported.
- A badly nested pattern can cause catastrophic backtracking and freeze the page for a while.
- The table lists the first 400 matches only.
Questions about this tool
What does the g flag do?
It makes the search global so every match is returned. Without it you get the first match only, and replace changes only the first one.
Do I double the backslashes?
No. Type the pattern as you would between the slashes of a literal, for example \d+, with no quotes or extra escaping.
Are named groups supported?
Yes, for example (?<year>\d{4}), and you can reuse it in the replacement as $<year>.
