JavaScript Regex Tester
Enter a JavaScript pattern and test text to inspect matches and captures. Every test runs in a worker that can be stopped.
Result
Matches in your text
Run a test to show matches.
Offsets use zero-based UTF-16 code units; end offsets are exclusive. Empty matches appear in the JSON output but cannot be highlighted.
Test regular expressions using your browser’s JavaScript engine
This tool uses JavaScript RegExp in a dedicated worker. It
never evaluates pasted JavaScript code. Enter the pattern body only, set
its flags separately, and run the test. Matches and captured groups are
rendered as literal text, including any HTML-looking input.
How to read the results
-
For a simple example, enter
\d+withgand test “Order 42 costs 15.” The results are “42” and “15”. -
Parentheses capture text.
(?<word>\w+)also names a group “word”. The output lists numbered captures and named captures; an unmatched optional capture isnull. -
Use
gto collect matches throughout the text. Without it, the tool returns the first match. Stickyyrequires a match at the current position, beginning at index 0. -
Use
dto include capture ranges when your browser supports it. Indexes count UTF-16 code units, so some visible characters take two positions.
Flags and common mistakes
i ignores case, m changes line-boundary behavior
of ^ and $, and s allows a dot to match line terminators. u and v enable different Unicode-aware modes and
cannot be combined. A flag or pattern unsupported by your current browser
produces an error. Do not wrap the pattern in quotes or double its
backslashes as you would inside a JavaScript string.
Timeouts, limits, and privacy
Some patterns can spend a long time backtracking. Each run starts a fresh worker, and the page terminates it after about one second or when you select Cancel. Changing any input cancels an active test and clears previous results. Browser scheduling can delay the timeout notice. There is no fallback that runs your pattern on the page’s main thread.
Results are limited to 1,000 matches or 500,000 code units of captured text. A limit notice means the results are incomplete. This tool is intended for bounded examples, not large files or other regex dialects such as PCRE. It does not fetch URLs or upload your test text. A timeout is a reason to simplify a pattern; it is not a complete performance or security audit.
For global patterns that match an empty string, the tool advances one code unit, or one Unicode code point in u/v mode, before finding another match. This avoids an infinite loop while preserving zero-length match positions.