🧪 Regex Tester

Test JavaScript regular expressions live — match, replace, or split, with capture-group breakdown.

/ /
Flags:
Mode:

g global · i case-insensitive · m multiline (^/$ per line) · s dotAll (. matches newlines) · u unicode · y sticky · d indices on captures

Samples:
🔍 Explain this regex
Type a pattern above to see a token-by-token breakdown.
📋 Copy as code
Runnable JavaScript snippet — paste into any console or playground.

      
📖 Cheat sheet

Anchors & classes

^ $start / end of string (line in m mode)
\b \Bword / non-word boundary
.any char except newline (matches all in s mode)
\d \Ddigit / non-digit
\w \Wword char / non-word char
\s \Swhitespace / non-whitespace
[abc] [^abc]any of / not any of
[a-z]character range

Quantifiers & groups

* + ?zero+ / one+ / optional
{n} {n,} {n,m}exactly / at least / range
*? +? ??lazy variants
(abc)capturing group
(?:abc)non-capturing group
(?<name>abc)named group — back-ref via $<name>
(?=abc)lookahead
(?!abc)negative lookahead
(?<=abc)lookbehind
(?<!abc)negative lookbehind
a|balternation

About Regex Tester

Write a JavaScript regular expression and watch it run against test text live — with a per-match capture-group breakdown, three modes (match / replace / split), and the standard flag toggles (g i m s u y d). Pure browser RegExp; no server, no remote evaluation.

How to use

  1. Type or paste a pattern in the slashes. You can paste a literal like /foo/gi and the flags split out automatically.
  2. Toggle the flag pills as needed. g is on by default in Match mode.
  3. Pick a mode — Match to see every hit and its captures, Replace to preview a substitution, Split to see how the regex slices the input.
  4. Try a sample from the dropdown if you need a starting point.

Common use cases

  • Validating that a regex actually matches what you think it does.
  • Building a non-trivial replacement (named groups, lookarounds) and previewing the output before committing it to code.
  • Splitting a delimited string and seeing exactly which empty strings end up in the result.
  • Debugging a regex that "works locally but fails in CI" — paste both inputs, compare match counts.

Tips

  • The d flag exposes start/end indices of every capture — invaluable when locations matter.
  • Match elapsed time is shown after every run; if it exceeds 200 ms the status bar warns about possible catastrophic backtracking.
  • This is the JavaScript flavor — features like atomic groups, recursion, and possessive quantifiers don't exist here. Stick to the cheat sheet at the bottom.

FAQ

Which regex flavor does this use?
JavaScript's built-in RegExp (the same engine your browser runs). It's close to PCRE but not identical — features like atomic groups, recursion, and possessive quantifiers don't exist here.
Why is my regex matching nothing?
Most often: the g flag is off (so only the first match shows), or the pattern is anchored to the start (^) or end ($) without m, or character classes need escaping. Check the flag pills and the cheat sheet at the bottom.
What does the d flag do?
It exposes the start/end indices of each capture group. Without it you only get the matched text; with it you get exact positions.
Can I test against a huge file?
Anything that fits in your browser memory. The status bar warns if a run exceeds 200ms, which usually means catastrophic backtracking — try rewriting nested quantifiers.
Are my regex and test text saved anywhere?
No. The page is a single static HTML file; nothing leaves your browser. We don't even persist to localStorage.

More tools

JSON

Code

Ornaments

Image

Web / SEO

Generators

PDF