Regex Tester
Test a JavaScript regular expression against your text and list every match, index and capturing group.
Result
Text with matches marked
Matches
How it works
The test runs in your browser using its JavaScript regular expression engine, the same one that runs on web pages. This is not PCRE, Python, Java, .NET or RE2, and their syntax and behaviour differ in places, so check a pattern in the language you will really use.
With the g flag every match is listed, and without it only the first. A match with no characters, such as one from a*, is listed at its position and the search always moves on, so it cannot loop forever. Indexes count UTF-16 code units, as JavaScript does, so an emoji takes up two positions. Line breaks and tabs in a match are shown as \n and \t in the list.
The pattern can be up to 1,000 characters, the text up to 100,000, and at most 1,000 matches are shown. A pattern that backtracks heavily can make your browser tab slow or unresponsive. This tool cannot prevent that, so close the tab if it happens.
What this result means
The result lists each match with its position and groups, using the JavaScript regular expression engine of your browser.
Examples
- The pattern \d+ with the g flag on "a1 b22": Two matches: "1" at index 1 and "22" at index 4
Assumptions and limitations
- Only JavaScript regular expressions are tested. Patterns for other languages can behave differently.
