Developer

Regex Tester

Test a regular expression against sample text with live match highlighting.

Highlighted matches
Match details

A regular expression that looks right rarely is right the first time — an unescaped dot, a quantifier that's greedier than intended, a character class missing one character you needed. The fastest way to find out is to see exactly what it matches against real text, not to reason about it in the abstract.

This runs your pattern through your browser's own JavaScript RegExp engine as you type, highlights every match inline, lists each match's capture groups, and can preview what a replace() would produce — all without sending the pattern or the text anywhere.

How to use it

  1. Type a pattern and tick whichever flags you need — g, i, m, s.
  2. Paste or type your test text — matches highlight as you type.
  3. Check the match list below for each match's position and any capture groups.
  4. Optionally fill in Replace with (using $1, $2 for groups) to preview a replace().

Questions

Why does an invalid pattern show an error instead of a result?

JavaScript's RegExp constructor throws for malformed patterns — unbalanced brackets, an invalid escape, a bad quantifier — and this surfaces that error message directly rather than guessing at what you meant.

Does the global flag change what highlights?

No — every match always highlights, since that is normally what you want to see while testing. The g flag instead controls whether the replace preview below rewrites every match or only the first one, exactly matching how String.replace() behaves in real code.

Is this the same regex engine as other languages?

No — this is specifically JavaScript's RegExp engine. Python, PCRE (used by many other tools) and JavaScript differ in some corners (named groups syntax, lookbehind support in older engines, a few escape sequences), so a pattern tested here is guaranteed to work in JavaScript, not necessarily verbatim elsewhere.