Skip to content
ToolsFort home

Regex Tester

Regex tester for JavaScript regular expressions: live match highlighting, capture groups and replace preview.

Updated

/ /

Matches

#MatchIndexGroups
Result

        
Quick reference
.
any character
\d \w \s
digit, word, whitespace
\D \W \S
negated classes
[abc] [^abc]
set / negated set
a* a+ a?
0+, 1+, 0 or 1
a{2,5}
between 2 and 5
^ $
start / end
\b
word boundary
(…) (?:…)
capture / non-capture
(?<name>…)
named group
a|b
alternation
(?=…) (?!…)
lookahead
(?<=…) (?<!…)
lookbehind
*? +?
lazy quantifiers

Write a pattern, paste some text and watch matches light up as you type. Capture groups, named groups and replacements are shown for every match.

How to use the Regex Tester

  1. 1 Enter your pattern (without slashes) and toggle flags.
  2. 2 Paste test text — matches are highlighted instantly.
  3. 3 Inspect groups in the matches table and preview replacements.

Worked examples

Emails

Input: \b(\w+)@(\w+)\.com\b with flags gi

Result: 2+ matches highlighted

Groups: user and domain

Dates

Input: (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})

Result: Named groups y, m, d

Replace with $<d>/$<m>/$<y>

Regex flags

Flag Meaning
g Find all matches, not just the first
i Case-insensitive
m ^ and $ match at line breaks
s . also matches line breaks
u Unicode mode (code points, \p{…} classes)
y Sticky — match only at lastIndex

Protection from catastrophic backtracking

Patterns such as (a+)+$ can take exponential time on some inputs and freeze a browser tab. This tester runs every match in a background worker and stops it after 1.5 seconds, so the page always stays responsive.

Runs locally

Everything happens in your browser — nothing you paste is uploaded or logged, so it is safe to use with API responses, tokens and internal data.

Frequently asked questions

Which regex flavour is used?

JavaScript (ECMAScript) regular expressions, as implemented by your browser — including lookbehind and named groups.

How do I use capture groups in the replacement?

Use $1, $2… for numbered groups, $ for named groups and $& for the whole match.

Why are zero-length matches not highlighted?

They have no width to highlight, but they are still listed in the matches table.

Esc