Regex Tester

Regex Tester

Test, debug and validate regular expressions in real time with match highlighting, capture group inspection, and flag support. Free, no signup.

Updated May 2026

/ /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

Pattern, flags, test string — everything updates live

1. Type your pattern

The token explanation panel breaks down each part of the regex the moment you type it, so you see exactly what it does.

2. Toggle flags and paste your test string

`g`, `i`, `m`, `s` change matching behavior — matches are highlighted live as you edit either field.

3. Copy the generated code

Switch between JavaScript, Python, and PHP and copy a ready-to-paste snippet with your pattern, flags, and string already filled in.

What this regular expression tester does

More than just highlighting matches

Token-by-token explanation

A dedicated panel explains what each part of your pattern means in plain English, updated in real time as you type.

Named and numbered capture groups

See every captured group — numbered and (?<name>...) — listed separately for each match, not buried in a single output string.

Code generator

Get a working JavaScript, Python, or PHP snippet with your pattern, test string, and flags already formatted correctly.

Ready-made pattern library

Load a starting pattern for email, URL, IPv4, phone number, date, or hex color and adapt it instead of writing from scratch.

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.

Sanitizing form input

Strip disallowed characters with a negated character class before storing anything a user submits.

Generating URL slugs

Turn a title into a safe slug by replacing spaces and special characters in one pass.

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 — enable it whenever you need every match, not just the first one.

Catastrophic backtracking

Nested quantifiers like (a+)+ against a long non-matching string can freeze the regex engine — and lock up the browser tab if it runs on the page.

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 directly and only paste it into the project once it actually matches what you expect — that saves real debugging time.

The token explanation panel and the ready-made pattern library make it useful whether you're still learning regex syntax or you already know it cold and just want to validate a pattern fast before committing it.

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