Regex Tester & Explainer: Live Matches, Groups, Code

Regex Tester & Explainer: Live Matches, Groups, Code

Test JavaScript regular expressions live: highlighted matches, capture groups, a plain-English explanation of each token, and code in JS, Python and PHP.

Updated November 2026

Reviewed by Rafael Duarte

/ /g
Test String
Code Generator
const regex = /your-pattern/g;
const str = `Contact support at help@blueprint-precision.com or send queries to admin@system.internal.
Please rea`;
let m;

while ((m = regex.exec(str)) !== null) {
  if (m.index === regex.lastIndex) {
    regex.lastIndex++;
  }
  // The result can be accessed through the `m` variable.
  m.forEach((match, groupIndex) => {
    console.log(`Found match, group ${groupIndex}: ${match}`);
  });
}
Regex Explanation

Enter a pattern above to see it explained token by token.

Pattern Library

How to use this regex tester

JavaScript regex engine, results update as you type

1. Type your pattern

Enter it in Regular Expression, without the surrounding slashes. The Regex Explanation panel describes each token in plain English as you type, or pick a ready-made pattern from the Pattern Library.

2. Set flags and paste your test string

Toggle Global, Case insensitive, Multiline and Dot all (g, i, m, s). Matches are highlighted under Live Results, with the match count and each match's capture groups listed below.

3. Take it to your code

Copy Pattern gives you /pattern/flags. The Code Generator has JavaScript, Python and PHP tabs with a snippet to start from; check it before use, since the test string is cut to 100 characters.

What this regular expression tester does

More than just highlighting matches

Plain-English explanation

The Regex Explanation panel lists the first 16 tokens of your pattern (classes, groups, lookarounds, quantifiers, anchors, escapes) with what each one does, and marks lazy quantifiers.

Capture groups per match

Each match is listed with its position and its groups numbered #1, #2 and so on. Named groups such as (?<year>...) work, but they're shown by number, not by name.

Code in JavaScript, Python and PHP

A starting snippet with your pattern, flags and the first 100 characters of your test string. The JavaScript version doesn't escape / inside the pattern, and the Python one keeps JavaScript group syntax and always uses re.findall.

Pattern Library

Seven starting points with sample text: Email Address, URL (Web), IPv4 Address, Phone Number, Date (YYYY-MM-DD), Hex Color and Brazilian CNPJ. They're deliberately simple: the email pattern allows 2 to 4 letter domain endings and the phone pattern follows North American formats.

Examples

See how common patterns behave against real text

Pattern
What it matches
\d+ against "Order 1234 on 2024-01-15"
1234, 2024, 01, 15
^(\d{4})-(\d{2})-(\d{2})$
Full match plus 3 capture groups
<.+> (greedy) against <b>bold</b>
The entire string — from the first < to the last >
<.+?> (lazy) against <b>bold</b>
Each tag separately: <b> and </b>

When you'll reach for a regex tester

The most common scenarios developers use it for

Validating email or phone input

Run the pattern against real edge cases before shipping it to a production form.

Parsing log files

Pull out timestamps, IP addresses, or error codes using anchors and character classes without writing a script first.

Checking what a cleanup regex will hit

Before running replace() with a negated class like [^a-z0-9-], paste sample input and see exactly which characters it catches. This page only finds matches; the replacing happens in your code.

Extracting dates, IDs and codes

Pull order numbers, ISO dates or hex colors out of a block of text and confirm the capture groups hold the parts you need.

Common regex mistakes

Forgetting to escape special characters

A bare . matches any character. To match a literal period, escape it as \.

Forgetting the g flag

Without it, only the first match is returned. Leave Global on whenever you need every match.

Expecting \w to match accented letters

In JavaScript without the u flag, \w only covers [a-zA-Z0-9_], so café matches as caf. This tester doesn't offer the u flag, so Unicode classes like \p{L} won't work here either.

Catastrophic backtracking

Nested quantifiers like (a+)+ against a long non-matching string can make the engine run for a very long time. This tester runs on the page itself with no timeout, so such a pattern can freeze the tab.

Why use this regex tester

Instead of sprinkling console.log through your code and re-running it every time you tweak the pattern, you iterate on the regex here and paste it into the project once it matches what you expect. It uses your browser's own JavaScript engine, so what matches here matches in JavaScript.

The plain-English explanation and the Pattern Library help while you're still learning the syntax; the live highlighting and numbered groups are quick enough for checking a pattern before you commit it. For five patterns worth knowing by heart, see Five Regular Expressions Worth Memorizing.

Greedy vs. lazy quantifiers

The most common reason a match is bigger than expected

Greedy (*, +, ?)
Lazy (*?, +?, ??)
Behavior
Matches as much as possible
Matches as little as possible
Example on <b>x</b>
<.+> grabs the whole string
<.+?> grabs each tag
Use when
You want the longest possible match
You want the shortest match between delimiters

Frequently asked questions

A regex tester lets you write a regular expression and instantly see which parts of a test string it matches, with visual highlighting and a breakdown of any captured groups. It replaces the trial-and-error of running your regex through actual code just to check whether it works.

References

Related Tools