Regex Tester

This regex tester matches as you type: write a pattern, paste some test text, and watch every match light up. Capture groups — numbered and named — are broken out in a table, replacements are previewed live, and a built-in library covers the patterns everyone ends up rewriting.

How to use Regex Tester

  1. Enter your pattern in the regex field, without the surrounding slashes.
  2. Toggle the flags you need: g for all matches, i for case-insensitive, m for multiline, s for dot-matches-newline.
  3. Paste test text below and see matches highlighted in place, with a table of positions and capture groups.
  4. Type a replacement using $1, $& or $<name> to preview the substituted result.
  5. Pick a ready-made pattern from the library, or check the cheatsheet for syntax reminders.

About Regex Tester

Regular expressions are the fastest way to describe the shape of text and the slowest thing in the world to debug in your head. The fix is immediate feedback: see every match highlighted in real data while you edit the pattern, and the guesswork disappears. This tester renders your test text with each match overlaid in place, so you can tell straight away whether a quantifier is greedy where it should be lazy, or whether an anchor is silently failing because you forgot the m flag.

Capture groups get first-class treatment, because they are usually the point. The match table lists every occurrence with its index, its full text and the value of each numbered and named group, which makes it obvious when an optional group is matching the empty string rather than not matching at all. The replace preview supports the full JavaScript substitution syntax — $1, $&amp;, $&lt;name&gt; and $$ — so you can build a rewrite rule and verify it against every line at once.

Two things separate a usable regex tester from a hazardous one. The first is honesty about the flavour: this is the JavaScript engine, so what works here works in Node and in the browser, and PCRE, Python and Go patterns may need adjusting. The second is not hanging. Backtracking engines can go exponential on innocuous-looking patterns, and no timer inside the page can stop a running match, so every pattern is executed on a worker thread that is terminated outright if it overruns 1.5 seconds. Structures known to cause catastrophic backtracking also raise a warning before they cost you anything.

Frequently asked questions

Which regex flavour does this use?

JavaScript’s, via the native RegExp engine — the same one that runs in Node and in the browser. That means lookbehind, named groups and Unicode property escapes are supported, while recursion, possessive quantifiers and PCRE-only constructs such as \K are not.

What do the flags actually do?

g finds every match instead of only the first, i ignores case, m makes ^ and $ match at line boundaries, s lets . match newlines, u enables full Unicode mode and y anchors each attempt to the previous match’s end.

Can a bad pattern freeze the page?

No. Certain patterns — typically nested quantifiers over overlapping alternatives such as (a+)+$ — take exponential time on the right input, a problem known as catastrophic backtracking. A JavaScript regex cannot be interrupted once it starts, so matching here runs on a separate worker thread: if a run has not finished within 1.5 seconds the thread is terminated and the page tells you what happened. Results are also capped at 5,000 matches, and a pattern containing a structure known to trigger the problem is flagged before you run it.

Is my test data private?

Yes. The pattern and the text are never sent anywhere; everything is evaluated in the page. Log lines and sample records frequently contain personal data, so local evaluation is not a nicety.

How do I use capture groups in a replacement?

Refer to a numbered group with $1, $2 and so on, to a named group with $&lt;name&gt;, to the whole match with $&amp;, and to a literal dollar sign with $$. The replace preview updates as you type so you can check the output before running it in code.

Why does my global regex skip every other match?

A RegExp object with the g flag carries a mutable lastIndex, so reusing the same object across calls resumes from where it stopped. In your own code, create the pattern fresh or reset lastIndex — the tester compiles a new instance for each run so results here are always complete.

Related tools

All developer tools · Browse all 56 free tools →