tomai
Log in
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.

Related tools

What Is a Regex Tester?

Regular expressions — patterns for searching and replacing text — are among the most powerful and most error-prone tools in programming. A misplaced backslash changes what matches, and a pattern that looks right on paper often surprises you against real data. This tester shows you live what a pattern actually does: every match is highlighted in the test string, numbered and named capture groups are broken down with their positions, and a replace preview shows the outcome using $1 or $ syntax. Flags g, i, m, s, u, and y are one click away, alongside a library of ready-made patterns for emails, URLs, IPv4 addresses, dates, hex colors, and phone numbers, plus a syntax reference table. It uses the JavaScript regex engine — the exact one browser code runs — so what you test here is what ships. Built for front-end developers, testers, and anyone processing text.

What this tool can do

  • 🔦 Live highlighting of every match as you type
  • 🧩 Numbered and named capture groups with match positions
  • 🔁 Replace preview using $1 and $ syntax
  • 🚩 Flags: g, i, m, s, u, y
  • 📚 Pattern library: email, URL, IPv4, date, hex color, phone
  • 📖 Built-in syntax reference table

When you will use it

  • Writing a validation pattern for a form field
  • Debugging why a regex matches too much or too little
  • Building a text-processing script that relies on capture groups
  • Checking a community pattern before copying it into production

Privacy: the pattern and test text are evaluated entirely in your browser — nothing is uploaded or logged. Free to use.

Related tools