Regex tester

Test regular expressions with live highlighting, capture groups and replace, plus ready patterns for email, Indian mobile numbers and PIN codes. Everything runs in your browser; nothing is uploaded.

Try:
Matches
Highlighted matches appear here.

Quick reference

\d \w \sdigit, word character, whitespace (uppercase = the opposite)
.any character except newline (with the s flag, also newline)
[abc] [^abc] [a-z]one of, none of, a range
* + ? {2,5}repeat: 0+, 1+, 0 or 1, 2 to 5 times (add ? to make it lazy)
^ $ \bstart, end (of line with m), word boundary
(…) (?:…) (?<name>…)capture group, non-capturing group, named group
a|ba or b
(?=…) (?!…)followed by, not followed by

This tester uses the JavaScript regex engine, the same as Node.js and browsers.

Questions

Why does my regex work here but not in Python or Java?

Each language has small differences, for example named groups are (?P<name>…) in Python. Simple patterns work the same everywhere.

How do I use a capture group in the replacement?

Use $1, $2 for numbered groups and $<name> for named groups. $& inserts the whole match.

Why only one match?

Without the g (global) flag JavaScript stops at the first match. Tick g to find them all.

Is my text sent anywhere?

No. Matching runs in your browser.

More tools