Developer Utilities

Regex Tester

Test JavaScript regular expressions in an isolated browser worker with match highlights, positions and captures.

Browser processing · No account required

JavaScript regular expression

g: all matches · i: ignore case · m: line anchors · s: dot includes newlines · u: Unicode · y: sticky matching.

Try an example

Processed locally in your browser. No uploads or external requests. Expressions execute only in an isolated browser worker, terminated after one second (including startup). Up to 1,000 matches, 32 capture groups and a 240,000-character report; positions are zero-based UTF-16 offsets. Empty test text is valid; zero-width matches appear in the positions report without an artificial highlighted character. Other regex engines can behave differently.

Matches and captures

Add your input, then run the tool to see results.
WORK WITH CONFIDENCE

Understand your results

For developers checking JavaScript patterns against an explicit test sample.

The expression is compiled inside a disposable browser worker. A one-second deadline terminates that worker if matching stalls; it never falls back to running the pattern on the main thread. Try \d+ with g against Order 42: the match text is 42 and its position identifies the source range. Captures and named groups appear in the structured report.

How to use this tool

  1. Enter a pattern without surrounding / characters, or choose an example.
  2. Select the intended flags and enter test text. Global mode reports repeated matches; without it, the first match is returned.
  3. Run the test, inspect highlights and zero-based positions, and simplify any expression that times out.

What the observations mean

Each match includes its text and start/end offsets, followed by numbered and named captures. Unmatched optional groups are null, distinct from a matched empty string.

Worked example

Extract numbers from a small text sample using JavaScript matching rules.

Pattern: \d+
Flags: g
Text: Order 42 contains 3 notebooks.

The matches are 42 and 3, with offsets into the original text. Add parentheses to inspect capture groups. Results are JavaScript regular-expression behavior, not a guarantee of compatibility with another language.

Limits and processing

Patterns run in a disposable local worker with a one-second deadline including startup. Bounds are 512 pattern characters, 50,000 text characters and 1,000 matches. Offsets use UTF-16 units; blocked workers produce an error rather than unsafe main-thread execution.

Common problems and practical fixes

Invalid pattern
Check delimiters, escaping, unmatched brackets and the selected engine flags.
Only one match
Enable g for repeated matches; sticky y requires matching at the current lastIndex.
Worker deadline reached
Reduce test text and avoid ambiguous nested repetition; a larger timeout is not a safe fix.

Best practices

Test representative failures as well as successes and keep expressions understandable to future maintainers.

Practical tips

  • Nested repetition can cause excessive backtracking even on short strings. A timeout is a safety stop, not a syntax diagnosis.
  • Offsets use UTF-16 code units, the same indexing convention as JavaScript strings. Unicode mode affects pattern semantics and zero-width advancement.
  • The worker supports g, i, m, s, u and y. Engine features can vary with browser version; PCRE, Python and .NET have different rules.
A LITTLE MORE CLARITY

Frequently asked questions

Practical answers for using the Regex Tester.

Does the test send my pattern to a server?

No. A same-origin static worker script runs in your browser. There is no Cloudflare analysis endpoint or external processing.

Why is there a match with no visible highlight?

Zero-width matches have empty text. Their offsets are listed, but no unrelated character is painted as a match.

What does a truncated report mean?

Matching stops at 1,000 results or a 240,000-character report. Up to 32 capture groups are supported. The count is the reported subset, not a proven total beyond a limit.