Test Regular Expressions

Type a pattern and a test string, and see every match highlighted live, with each capture group broken out. Nothing is sent anywhere.

Test Regular Expressions

How it works

  1. Type or paste a regular expression pattern, and choose which flags apply (g for every match, i for case-insensitive, and so on).
  2. Paste the text you want to test it against. Every match highlights immediately as you type either field - no button to click.
  3. If your pattern has capture groups, each match's groups are broken out into their own table below, by number or name.
Example output

Input

/(\w+)@(\w+\.\w+)/g

Contact us at hello@example.com or support@example.org for help.

Output

Match 1: "hello@example.com" at 14-31
  Group 1: "hello"
  Group 2: "example.com"
Match 2: "support@example.org" at 35-54
  Group 1: "support"
  Group 2: "example.org"

Two matches, each with two capture groups (the name and the domain) - the real output for this pattern and text.

Frequently asked questions

Is my pattern or text sent anywhere?

No. Matching runs entirely on your device - in a background thread inside your own browser - and nothing is sent to a server. Turn off your Wi-Fi after the page loads and it still works. This page loads 4KB of JavaScript, gzipped - about what your browser's network tab will show for this page's own scripts.

Why does matching run in a background thread instead of instantly?

A regular expression can be written (often by accident) in a way that makes a single match attempt take an extremely long time against certain text - this is called catastrophic backtracking, and a pattern like (a+)+b against a long run of "a"s with no trailing "b" is a classic example. That single match call can't be interrupted from JavaScript once it starts. Running it in a background thread means this tool can forcibly stop a stuck match after a few seconds and tell you what happened, instead of freezing the whole page.

What regex flavor does this use?

Your browser's own native JavaScript RegExp engine - the exact same engine that runs a regex literal like /foo/gi in any JavaScript code, so a pattern that works here will behave identically in your own JavaScript.

What do the flag checkboxes do?

g (global) finds every match instead of stopping at the first. i ignores case. m (multiline) makes ^ and $ match at the start/end of each line, not just the whole string. s (dotAll) makes . match newline characters too, which it otherwise doesn't. u enables full Unicode handling (correct matching of characters outside the Basic Multilingual Plane, and stricter pattern validation).

How are capture groups shown?

Every match that has capture groups gets its own rows in the table below the highlighted text - one row per group, showing the group's number (or name, for a named group like (?<year>\d{4})) and the exact text it captured. A group inside an alternative that didn't match (like the "a" branch of (a)|(b) when "b" is what matched) shows as "no match" rather than a blank or misleading value.

Files are processed locally in your browser and never uploaded. Read more on the privacy page.