How to test a JavaScript regular expression
- Enter the JavaScript Pattern without surrounding slash delimiters.
- Choose Flags and enter Test text. The g flag is selected by default.
- Select Test regex to see highlights, positions and groups. Select Cancel to stop a running test.
Test JavaScript patterns and flags with a regular expression tester
Enter your regular expression without surrounding / delimiters—for example, (?<size>[0-9]+) against size 12 highlights 12 and extracts the named size capture group. This regular expression tester and pattern tester uses your browser’s native JavaScript RegExp engine, supporting lookahead ((?=...), (?!...)), lookbehind ((?<=...), (?<!...)), character classes and Unicode property escapes (\p{...} with u or v). The global g flag is enabled by default; toggle i for case-insensitive matching, m for multiline ^ and $ anchors, s for dotAll, or d to inspect capture start and end indices.
Inspect zero-based match positions and capture groups
Highlighted spans show every match in context, while the match table lists the zero-based UTF-16 string index, full match text, and numbered or named capture groups. Optional groups that did not participate are labeled Unmatched, and zero-length matches (such as word boundaries \b or lookarounds) are marked with a vertical bar.
Worker timeout protection against catastrophic backtracking
Patterns up to 2,048 characters and sample text up to 64 KiB (returning up to 1,000 matches) execute inside an isolated Web Worker on your device. If nested quantifiers trigger catastrophic backtracking and run longer than about one second, the worker terminates cleanly so your browser tab never freezes. Once your pattern works, apply it to a draft in find and replace text, check length in the word counter, or inspect payloads in the JSON formatter.
Frequently asked questions
Which regular expression engine is used?
The tool uses your browser’s JavaScript RegExp engine. Available syntax and flags depend on that browser.
How are positions counted?
Positions start at zero and count JavaScript UTF-16 code units. Some characters, including many emoji, occupy two code units.
What does the g flag do?
It finds successive matches. Without g, the tester returns the first match the selected flags allow.
Can I test an empty match?
Yes. A pattern such as ^ can match a position without consuming characters. A vertical marker shows that position.
What happens when a test takes too long?
The browser worker stops after about one second. You can simplify the pattern or shorten the text and run it again.
Last updated November 11, 2026