✦ tomai
Free · Developer Tools

Regex Tester

Test regular expressions live with match highlighting, groups and replace

/ /
Common patterns
Matches
Result

  
Quick reference
\d \w \sdigit, word char, whitespace
^ $ \bstart, end, word boundary
* + ? {n,m}0+, 1+, optional, range
(…) (?:…) (?<name>…)capture, non-capturing, named
[abc] [^abc] [a-z]any of, none of, range
a|b (?=…) (?!…)alternation, lookahead

Catastrophic backtracking, contained

Nested quantifiers such as (a+)+$ can make a matcher explore exponentially many paths — the classic ReDoS trap:

  • This tester wraps your pattern in a worker with a step budget; a runaway match is aborted and reported instead of freezing the tab.
  • If you see an abort, the pattern is dangerous in production too — no amount of server timeout fixes a quadratic engine loop.
  • Fixes that usually work: make inner groups unambiguous, anchor both ends, replace greedy nesting with character classes.

How this tester runs patterns safely

⚡

Live match highlighting

Pattern, test string, and replacement update as you type: matches glow in alternating colors, the count refreshes, and the replace preview applies $1 and named-group syntax like $<name>.

🔒

Groups with positions

Every match expands into numbered and named capture groups with their values and character positions, so it is clear which part of the pattern captured what before the pattern ships.

🎯

Flags, library, reference

Flags g, i, m, s, u, and y sit one click away, six ready-made patterns cover email, URLs, IPv4, dates, hex colors, and phone numbers, and a syntax reference walks through anchors, quantifiers, groups, and lookarounds.

Frequently asked questions

Which regex flavour does this use?

The JavaScript (ECMAScript) engine built into your browser. Most syntax is shared with PCRE, but a few things differ — e.g. no possessive quantifiers, and lookbehind requires a modern browser. Patterns you test here behave exactly as they will in JS code.

Is my text sent anywhere?

No. Matching, grouping and replacement all run locally with your browser’s native RegExp, so your patterns and test data never leave the page. It works offline too.

Can a regex freeze the page?

A pathological pattern (catastrophic backtracking) can be slow, but only in your own tab. We advance past zero-width matches and cap results at 10,000 to keep the UI responsive. Prefer specific patterns over nested quantifiers like (a+)+ on long input.

Why does my pattern hang on some inputs but not others?

Backtracking cost depends on input shape, not just length: aaaa...b against (a+)+b explodes, while aab finishes instantly. Attackers craft exactly those pathological strings, so test with long same-character runs before shipping any user-facing regex.

What Is a Regex Tester?

A regex tester compiles your pattern with the flags you tick and runs it live against your test string, so searching and replacing stops being guesswork. Every match is highlighted inline with alternating tones, listed with its character index, broken down into numbered and named groups where a (?<name>...) group shows its label and unmatched groups honestly read undefined, and a replace box previews the substitution result as you type, all starting from a sample sentence preloaded in the editor.

From email extraction to replacement previews

  • Toggle the g, i, m, s, u and y flags, with global on by default, and load one of six starter patterns covering email, URL, IPv4, dates, hex colors and phone numbers to learn by example rather than from a blank box.
  • Type a replacement using positional or named references and watch the result pane update instantly, consulting the six-row syntax reference for classes, anchors, quantifiers, groups, sets and alternations with lookarounds.

Runaway patterns, caps and single-shot mode

  • An invalid pattern shows the engine message verbatim instead of failing silently, global matching stops after ten thousand hits with a capped notice, and without the global flag only the first match is returned, which surprises newcomers.
  • Empty patterns match nothing by design, and zero-width hits advance the search position internally so the tester never hangs in an infinite loop on patterns that match empty strings.

The whole lab runs on page script with no backend and no telemetry calls, so proprietary logs and patterns remain yours. Unplug the network and every highlight, group and preview keeps working.

Last updated · 2026-09-01

Related tools

Related tools