Skip to content
Tools

Regex tester

Test JavaScript regular expressions with live matching.

Quick reference

.
Any character
\d
Digit [0-9]
\w
Word character
\s
Whitespace
^
Start
$
End
*
0 or more
+
1 or more
?
0 or 1
{n}
Exactly n
[abc]
Character set
(abc)
Group

About the Regex tester

This regex tester runs a regular expression against your sample text as you type, highlighting every match and listing capture groups. Use it to build or debug a pattern before putting it in code. It uses your browser's JavaScript RegExp engine, so results match what JavaScript and TypeScript code will do, and nothing is sent to a server.

How to use it

  1. Type a pattern between the slashes in the Pattern field, or click Load example for an email pattern.
  2. Toggle flags with Global, Ignore case, Multiline and Dot all, or type flags directly in the flags box.
  3. Paste text into Test string. Matches are highlighted and listed with their index and groups.
  4. Click the copy icon to copy the regex as a literal, such as /\d+/g.

Flags

g finds all matches, i ignores case, m makes ^ and $ match at line breaks, and s lets . match newlines. Without g, only the first match is shown.

Errors and groups

An invalid pattern shows the JavaScript error message under the field. Each match lists its numbered capture groups as $1, $2 and so on.

Engine differences

Because this is the JavaScript engine, syntax from other flavors may behave differently. For example, PCRE features such as possessive quantifiers are not supported.

Questions

Why does my regex only find one match?
The g (Global) flag is off. Without it, JavaScript stops after the first match.
Why doesn't ^ match the start of each line?
By default ^ and $ match only at the start and end of the whole string. Turn on the m (Multiline) flag to make them match at each line.
How do I match across newlines with a dot?
Turn on the s (Dot all) flag, or use [\s\S] in place of the dot.