Regex Tester

Test a JavaScript regular expression with live matches, groups and a replace preview.

Flags
Cheat sheet
.
any character except a line break (with s: any)
\d \w \s
digit, word character, white space (\D \W \S: not)
[abc] [^abc] [a-z]
one of, none of, a range
^ $
start and end (of each line with m)
\b
word boundary
* + ?
0 or more, 1 or more, 0 or 1
{2} {2,} {2,5}
exactly, at least, between
*? +?
as few as possible (lazy)
(abc)
capture group, $1 in the replacement
(?<name>abc)
named group, $<name> in the replacement
(?:abc)
group without capturing
a|b
a or b
(?=a) (?!a)
followed by, not followed by
(?<=a) (?<!a)
preceded by, not preceded by
$& $` $'
in the replacement: the match, text before, text after

How to use

  1. Type a pattern and tick the flags you need (g for every match).
  2. Paste the test text; matches are highlighted as you type.
  3. Read each match's position and groups in the list.
  4. Add a replacement such as $1 or $<name> to preview the result, then copy it.

Privacy

Runs in your browser. Nothing is uploaded. Matching runs in a separate browser thread that is stopped after 1.5 seconds.

Text and files you open stay on this device; closing the tab clears them. Inputs are limited to 5 MB so the page stays responsive.