Regex Tester
Test JavaScript regular expressions with visible matches, UTF-16 positions and capture groups. A dedicated worker deadline stops runaway backtracking.
Find the match and understand it.
IN YOUR BROWSER / PRIVATE INPUTHow to use the
Regex Tester
- 01
Enter a pattern and flags
Use the pattern without surrounding slash delimiters. Select JavaScript flags such as g, i, m, s or u as needed by your browser engine.
- 02
Add representative text
Include successful examples, near misses, empty values and line breaks. Test input is limited to 100,000 characters.
- 03
Inspect matches and captures
Review highlighted text, indices and capture groups. Simplify a pattern that exceeds the worker’s one-second execution deadline.
The browser JavaScript engine defines the behavior
The tool constructs a real RegExp in a disposable worker. A global flag is added when necessary to collect results, while the other supplied flags remain in effect. Invalid syntax or duplicate flags produce the engine’s actual error.
This is not a universal PCRE, Python or Java regex emulator. Supported features and Unicode behavior follow your browser. Match indices use JavaScript UTF-16 code-unit positions, which can differ from visible character counts when supplementary characters or combining sequences are present.
Separate the whole match from a capture group
Use a small representative sample while designing a pattern, then add difficult near misses. A pattern that finds one successful example can still behave badly on a long input that almost matches.
Pattern: (\d+)
Flags: g
Text: Outgle 42 and 8Match 1: 42, capture 1: 42
Match 2: 8, capture 1: 8A worker prevents catastrophic backtracking from freezing the page
Nested or overlapping quantifiers can cause some patterns to try an enormous number of paths. The main page starts an execution deadline after the worker has loaded; if matching exceeds one second, the worker is terminated and an actionable error is shown.
The result display is capped at 200 matches. Empty matches advance explicitly to avoid an endless collection loop. Highlighting shows a bounded text preview, while the JSON export contains the collected match data. A timeout is a signal to simplify or bound the expression, not proof that the intended language is impossible to recognize.
Build patterns that survive real input
Test failures as well as successes
Include long near matches and unexpected punctuation, not only the easiest positive example.
Choose anchors deliberately
^ and $ interact with the multiline flag. A search for part of a string is different from whole-value validation.
Escape data before inserting it into a pattern
User-provided literal text is not automatically regex syntax. This tester does not turn an unsafe application pattern into a safe validator.
Regex Tester:
questions, answered.
Why are regex match positions different from visible character counts?
JavaScript indices count UTF-16 code units. Some Unicode characters use two units, and a visible grapheme can contain multiple code points.
Why did my regex test time out?
The worker exceeded one second of execution, often due to expensive backtracking. Simplify overlapping quantifiers, add useful bounds or shorten the test input.
Can this tester use PCRE-specific syntax?
It uses the browser’s JavaScript RegExp engine. Syntax from another engine may be unsupported or behave differently.
How does the tester handle an empty regex match?
It advances the search position explicitly, respecting Unicode mode where relevant, so collecting zero-length matches does not loop forever.
The calculations and checks above describe this tool's implementation. Use these primary references for the underlying formats and publishing guidance.
JavaScript RegExp reference ↗ (opens in a new tab)Find the match and understand it.
Use the controls above, inspect the actual result and keep the source until you are ready to use your new copy.
Use the Regex Tester↑