Regex Tester

Test and debug regular expressions with live match highlighting, capture groups, and replace preview — all in your browser.

/ /
Test String
Matches
#IndexMatch
No matches
Replace
Quick Reference

Character classes

.
Any char (except newline)
\w
Word char [a-zA-Z0-9_]
\d
Digit [0-9]
\s
Whitespace
\W \D \S
Negated versions
[abc]
Any of a, b, c
[^abc]
Not a, b, c
[a-z]
Range

Quantifiers

*
0 or more (greedy)
+
1 or more (greedy)
?
0 or 1 (greedy)
{n}
Exactly n
{n,}
n or more
{n,m}
Between n and m
*? +?
Lazy versions

Anchors

^
Start of string/line
$
End of string/line
\b
Word boundary
\B
Non-word boundary

Flags

g
Global (all matches)
i
Case insensitive
m
Multiline ^$
s
Dot matches \n
u
Unicode mode

Groups

(abc)
Capture group
(?<n>abc)
Named group
(?:abc)
Non-capturing
\1
Backreference to group 1

Replace tokens

$&
Whole match
$1 $2
Capture group n
$$
Literal $

Lookaround

(?=abc)
Lookahead
(?!abc)
Negative lookahead
(?<=abc)
Lookbehind
(?<!abc)
Negative lookbehind

Alternation

a|b
a or b

Online Regex Tester & Debugger

Regular expressions are powerful but easy to get wrong. This tool lets you write a pattern, paste sample text, and instantly see which parts match — with color-coded highlights so you can tell matches apart at a glance. No page reloads, no login, nothing sent to a server.

Live match highlighting

As you type your pattern, every match in the test string is highlighted using a transparent overlay. Up to three alternating colors (purple, pink, teal) cycle across consecutive matches so overlapping or adjacent results stay distinguishable. Capture groups appear as extra columns in the Matches table below the editor.

Capture groups & named groups

Wrap any part of your pattern in parentheses to create a capture group. The Matches table gains a new column for each group — $1, $2, and so on. Use named groups like (?<year>\d{4}) and the column header shows the name instead of a number.

Replace & substitution preview

Enter a replacement string to preview the result of a String.replace() call in real time. Use $& to insert the whole match, $1$9 for capture groups, or $$ for a literal dollar sign. Copy the result with one click.

Regex flags

Toggle any of the five standard JavaScript flags directly in the toolbar: g (global — find all occurrences), i (case-insensitive), m (multiline — ^ and $ match per line), s (dotAll — . matches newlines), u (full Unicode support).

Frequently asked questions

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to match, find, or replace text in strings and is supported natively in JavaScript, Python, Java, PHP, and most other languages.

How do I test a regex for email validation?

Paste a pattern like [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}, enable the i flag for case-insensitivity, and enter sample email addresses in the test string. Matches indicate valid-looking emails.

What regex flags does this tool support?

All five standard JavaScript flags: g (global), i (case-insensitive), m (multiline), s (dotAll), and u (unicode).

How do I use capture groups?

Wrap part of your pattern in parentheses: (\w+)\s(\w+). Each group gets its own column ($1, $2…) in the Matches table. Named groups ((?<first>\w+)) show their name as the header.

Is my data sent to a server?

No. Everything runs client-side in JavaScript. Your patterns and test strings are never transmitted to any server.