Local browser utility

Regex Tester

Test JavaScript regular expressions against your own text, with every match, numbered and named capture group, and a live replacement preview.

Flags

This runs the browser’s own engine, so the flavour is JavaScript (ECMAScript) — not PCRE. Atomic groups, possessive quantifiers, recursion and /x mode do not exist here.

Test string

1 line · 0 characters

Matches

Replace (optional)

Use $& for the whole match, $1 and $<name> for capture groups, $` for the text before it and $' for the text after.

Output

Matched locally in your browser No data is sent to any server

Worked Examples

Named groups from an email-shaped string

Input
Pattern (?<user>\w+)@(?<domain>[\w.]+) · flags g · text "write to sam@example.com today"
Output
Match 1 at index 9: sam@example.com $<user> = sam $<domain> = example.com

Named groups are reported by name rather than as $1 and $2, which is what the $<name> replacement syntax refers to.

A group that did not participate

Input
Pattern (cat)|(dog) · text "dog"
Output
Match 1 at index 0: dog $1 = (did not participate) $2 = dog

The first alternative never ran, so $1 is undefined rather than empty. Treating those as the same value is a common source of null errors downstream.

The dot does not cross a newline by default

Input
Pattern a.b · text "a\nb"
Output
No matches. Adding the s flag produces one match.

In JavaScript the dot excludes line terminators unless the dotAll flag is set. Patterns moved from a language where the dot matches everything fail here silently.

Questions About This Tool

Which regex flavour does this use?

JavaScript, also called ECMAScript, because the matching is done by the browser you are reading this in. That differs from PCRE in ways that matter: no atomic groups, no possessive quantifiers, no recursion, and no /x mode. A pattern verified here is verified for JavaScript specifically.

Why does my pattern only find the first match?

The global flag is off. Without g, the engine stops at the first match by design. Tick the g checkbox to collect every match.

Why does a group show “did not participate” instead of empty?

Because the two are genuinely different. A group in an alternative that never ran is undefined; a group that matched zero characters is an empty string. Code that treats them the same is where undefined errors come from.

Do I include the slashes around my pattern?

No. The slashes are JavaScript source syntax for writing a regex literal, not part of the expression. Typing them makes them characters to match. Use the flag checkboxes for the trailing g, i and friends.

Is my test text sent anywhere?

No. The pattern and the text are matched by your own browser. There is no request, and you can confirm that in the network tab.

Can I use this to validate email addresses?

You can, but the result will be worse than you expect. The real grammar is far more permissive than the patterns circulating online, which reject valid addresses. Checking for an @ with something either side, then sending a confirmation message, is the approach that actually works.