Skip to content
Toolbench

Regex Tester

Test a regular expression against your text: every match, its position and its groups.

Runs entirely in your browser

Loading tool...

How to use

  1. Type a pattern — no surrounding slashes needed.
  2. Turn on the flags you want; g is applied for the preview so you see every match.
  3. Paste the text to search. Matches are highlighted as you type.
  4. Add a replacement to preview a substitution, using $1 or $<name> for groups.

Features

  • Every match with its position, numbered groups and named groups.
  • Highlighting that reassembles to exactly your original text.
  • Replacement preview with $1 and $<name> references.
  • Warns about patterns that can hang a browser, and about ones that match nothing.
  • Runs in your browser — nothing you paste is uploaded.

Frequently asked questions

Why does it show every match when I have not set the g flag?
Because a tester that showed one match for a pattern with five would be describing itself rather than your pattern. The preview always searches globally; the warning reminds you that in code, without g, you get only the first match. Replacement respects the flag exactly — with g it replaces everywhere, without it once.
What is catastrophic backtracking?
Some patterns take exponential time on inputs that nearly match. `(a+)+b` against a long run of a's tries every way of splitting them before giving up. JavaScript's engine cannot be interrupted once matching starts — there is no timeout — so a browser tester can only limit what it feeds in. This one caps the subject and the match count, and warns on the shapes that cause it. That is a mitigation, not a guarantee.
Why is there a length limit on the text?
Twenty thousand characters, for the reason above: the risk of a hung tab grows with the subject, and the tab cannot be rescued once a bad match begins. Long enough for real text, short enough to stay survivable.
Is this the same regex my language uses?
It is JavaScript's, which differs from PCRE, Python and Go in places — lookbehind support, named group syntax, and how unicode properties work. Patterns that use only the common syntax behave the same everywhere; anything exotic is worth checking in the language you will ship it in.

Compare two blocks of text and see exactly which lines were added, removed or changed.

Format and beautify JSON instantly.

Break a URL into its scheme, host, path, query parameters and fragment.

Regex Tester — Matches, Groups and Replace