WHAT IT DOES
The engine testing your pattern is the one that will run it.
Write a pattern, choose its flags, and see every match in your text with its position and its capture groups. Matching runs in your browser's own RegExp implementation, so what you see here is exactly what your JavaScript will get. A replacement string previews the result of .replace() with the same pattern and flags.
Why use it?
Use it to check matches, capture groups, and replacement behavior before using a JavaScript regular expression on real input.
How to use this tool
- Enter the pattern, flags, and representative text, then test. Include both text that should match and text that should not.
- Inspect match positions and groups; add a replacement string if you need a replacement preview. For example, use [0-9]+ with g to find each numeric run.
- Use the same flags as your application. Results describe the browser's JavaScript engine, not Python, Go, or PCRE, and pathological patterns may still take time to evaluate.
Details and limitations
- This is JavaScript regular expression syntax, not PCRE, RE2, Go, or Python. Lookbehind, named groups, and Unicode property escapes work; recursion, atomic groups, and possessive quantifiers do not exist here.
- Every match is listed with the characters it spans and each capture group beneath it, named where the pattern names them and numbered where it does not; a group that did not participate says so rather than showing an empty value.
- The whole subject is shown with matches highlighted, built from text nodes rather than from generated markup, so a pattern that matches an HTML tag highlights it instead of becoming it.
- A pattern that can match the empty string advances by one character rather than repeating the same match forever.
- The search stops after 500 matches or half a second, whichever comes first, and says which of the two stopped it.
- Test text is limited to 100,000 characters, because a browser cannot interrupt a regular expression once it has started and a badly backtracking pattern would freeze the page.