DevTools
All tools

Regex Tester

Test regular expressions and highlight matches and capture groups.

What is the Regex Tester?

The Regex Tester runs your pattern through the browser's native JavaScript RegExp engine and shows, in real time, exactly where it matches your test string. As you type, matched spans are highlighted directly over the text, and you also see the total match count and the capture groups for each match.

You can toggle the five flags — g (global), i (case-insensitive), m (multiline), s (dotAll), and u (unicode) — with a single click, so it's easy to compare how a flag changes the result. If a pattern is invalid, the tool shows the exact error message the browser returns, making it quick to pinpoint the syntax problem.

All matching and highlighting run entirely in your browser in JavaScript; the pattern and test string are never sent to a server. That makes it safe to validate patterns against logs or text containing sensitive data, since nothing leaves your machine.

How to use

  1. Enter just the pattern body (no surrounding slashes) in the pattern field. For example, to find a three-digit and four-digit number, type \d{3}-\d{4}.
  2. Click the flag buttons (g, i, m, s, u) below the field to enable the options you need. Turn on the g flag to find every match rather than just the first.
  3. Paste your text into the test string area. Matches are highlighted, and the match count and capture groups appear below. Use the copy button to grab all matched values at once.

Frequently asked questions

Which regex syntax is supported?
It uses the browser's built-in JavaScript RegExp engine, so it supports ECMAScript regex syntax as-is. Modern features like lookahead, named groups, and Unicode property escapes work to the extent your browser supports them.
There are several matches but I only see one.
Without the g (global) flag, only the first match is returned. Enable the g flag to find every match across the string.
How do I inspect capture groups?
Define capture groups with parentheses in your pattern, and for each match the group numbers and values appear in the Capture groups section. Optional groups that didn't match are shown as an em dash (—).
What happens with a very large number of matches?
To guard against runaway computation, matches are collected up to a cap of 1,000. When the cap is reached a notice is shown and no further matches are counted.
Are my pattern and text stored on a server?
No. All matching runs only in your browser, and the pattern and test string are never sent to a server.