Skip to content
Webmaster Tools
Dev utilitiesRegex Tester

Regex Tester

Live matches and groups.

Highlighted No matches

        

Matches

#IndexMatchGroups
Replace
Result

      

About the Regex Tester

This tester runs your pattern with the browser's JavaScript RegExp engine, so results match what your JavaScript code will do. Matches are highlighted in the test string as you type, and a table lists each match with its index, numbered capture groups ($1, $2, ...) and named groups ((?<name>...)). A replace panel previews String.prototype.replace with $1, $<name> and $& in the replacement.

Toggle the flags g (global), i (ignore case), m (multiline, so ^ and $ match at line breaks), s (dotAll, so . matches newlines), u (Unicode) and y (sticky). Everything runs locally.

How to use it

  1. Type a pattern between the slashes; no need to escape /.
  2. Pick flags.
  3. Paste text into the test string and review the highlighted matches and groups.
  4. Optionally enter a replacement to preview the result.

Examples

Pattern:      (\w+)@(?<domain>[\w-]+\.[\w.]+)   flags: g
Text:         Contact alice@example.com or bob@mail.example.org
Matches:      alice@example.com  ($1 = alice, domain = example.com)
              bob@mail.example.org  ($1 = bob, domain = mail.example.org)
Replacement:  $1 at $<domain>
Result:       Contact alice at example.com or bob at mail.example.org

Common questions

Why does it only find the first match?

Without the g flag, JavaScript stops after the first match. Turn on g to find all of them.

Is this the same as PCRE or Python regex?

Mostly, but not entirely. JavaScript has no possessive quantifiers, atomic groups or inline modifiers like (?i), and it writes named groups as (?<name>...) rather than Python's (?P<name>...).

Why does . not match a line break?

By default . excludes line terminators. Enable the s (dotAll) flag, or use [\s\S].

What does the u flag do?

It treats the pattern as Unicode code points, so emoji and other astral characters count as one character, and it enables \p{...} property escapes such as \p{L}.