Skip to content
OnlineToolStudio

Regex Tester

runs in your browserno sign-upfree

Test JavaScript regular expressions live — matches highlighted, with capture groups and flags.

//g

3 matches

156 chars
Matches highlighted
Contact us at support@example.com or sales.team@example.co.in. Old address: info@old-site.org (no longer used). Not an email: user@localhost, @handle, name@

Match details

#MatchPositionGroups
1support@example.com14–33
$1 support
$2 example.com
user support
domain example.com
2sales.team@example.co.in37–61
$1 sales.team
$2 example.co.in
user sales.team
domain example.co.in
3info@old-site.org76–93
$1 info
$2 old-site.org
user info
domain old-site.org

Quick reference

.
Any character except a new line
\d \w \s
Digit, word character (a–z, 0–9, _), whitespace
\D \W \S
Not a digit / word character / whitespace
[abc] [^abc] [a-z]
One of, none of, a range
^ $
Start and end of the text (or line, with m)
\b
Word boundary
* + ?
0 or more, 1 or more, 0 or 1
{3} {2,5} {2,}
Exactly 3, 2 to 5, 2 or more
*? +?
As few as possible (lazy)
(abc)
Capture group — $1, $2…
(?<name>abc)
Named capture group
(?:abc)
Group without capturing
a|b
a or b
(?=abc) (?!abc)
Followed by / not followed by
(?<=abc) (?<!abc)
Preceded by / not preceded by
\. \* \\
Escaped special characters

About this tool

This regex tester checks a regular expression against your text as you type. Every match is highlighted, and the match details show where each one is and what each capture group — numbered or named — contains. It uses your browser’s JavaScript engine, so the results are exactly what your JavaScript or TypeScript code will get. A quick reference of the most-used regex syntax is included below.

How to use

  1. Type your regular expression between the slashes, without the surrounding / /.
  2. Tick the flags you need — g to find every match, i to ignore case, and so on.
  3. Paste your test text. Matches are highlighted instantly and listed with their groups. Copy the ready-to-use JavaScript literal.

FAQ

Why does it only find the first match?

Without the g (global) flag, JavaScript stops at the first match — the tester shows exactly what your code would do. Tick "g — all matches" to find every match.

Will my regex work the same in PHP, Python or Java?

Most everyday syntax — \d, \w, [a-z], groups, quantifiers and lookaheads — is the same everywhere. Some features differ: for example PHP uses preg_match_all() instead of the g flag, and named groups are written (?P<name>…) in older Python code. Test in your own language for advanced patterns.

What are capture groups?

Parentheses ( ) capture the part of the match inside them, so you can use it separately — as $1, $2… in a replacement, or match[1] in code. (?<name>…) gives a group a name, and (?:…) groups without capturing.

The page froze with my pattern — why?

Some patterns, such as (a+)+b, can take extremely long on certain text ("catastrophic backtracking"). Avoid nesting repeats like (x+)+ and make patterns as specific as possible.

Related tools

All tools