Regex Tester

Validate JavaScript RegExp patterns in the browser and inspect flags, matches, capturing groups, and replacement output on one page.

Flags

This tool follows JavaScript `RegExp` behavior. The `g` flag affects both match collection and replacement scope.

Common test cases

If your browser supports lookbehind, named groups, and other modern RegExp features, you can test them here as well.

Everything stays in your browser. However, JavaScript regex syntax is not identical to PCRE, Python, Java, or grep, so verify engine differences when your production runtime is not JavaScript.
The regex is valid. With the current flags, 3 matches were found.

Execution summary

Regex literal/(?<user>[A-Z0-9._%+-]+)@(?<domain>[A-Z0-9.-]+\.[A-Z]{2,})/gi
Active flagsgi
Match count3
Unique match values3
Execution modeGlobal scan with `g`

Match results

Match 1Index 9 to 28
hello@toolivers.com

Capturing groups

$1hello
$2toolivers.com

Named groups

userhello
domaintoolivers.com
Match 2Index 30 to 47
admin@example.org

Capturing groups

$1admin
$2example.org

Named groups

useradmin
domainexample.org
Match 3Index 67 to 83
SALES@company.io

Capturing groups

$1SALES
$2company.io

Named groups

userSALES
domaincompany.io

Replacement preview

Enter a replacement string to preview JavaScript `String.prototype.replace()` with the current flags.

Replacement preview
Contact: hello at toolivers.com, admin at example.org, invalid@local
CC: SALES at company.io

The `g` flag is active, so replacement is applied across the full text.

Regex tester guide

A regex tester is most useful when it goes beyond syntax validation and shows what the pattern actually does to real text. Small differences in grouping, greediness, anchors, and flags can easily turn into production bugs when working with validation rules, log parsing, text cleanup, frontend form handling, or API response post-processing. This tool is designed to make JavaScript regex behavior visible in one place: pattern, flags, matches, groups, and replacements.

When this tool is especially useful

  • Checking whether a validation pattern really matches the examples you expect
  • Extracting tokens from logs, CSV data, markup, or templated strings
  • Previewing replacement output before changing date, code, or text formats
  • Debugging capture groups and named groups in a JavaScript code path

Flag tips

  • Check `g` first because it changes both how many matches you see and how replacement behaves.
  • `m` only changes how anchors like `^` and `$` behave. Use `s` when `.` must span line breaks too.
  • `u` matters for emoji and multilingual text because parsing becomes Unicode-aware.
  • `y` is more specialized and is most useful for tokenizers or position-sensitive parsing.

Common mistakes

  • Assuming JavaScript, PCRE, Python, Java, and grep regex syntax all behave the same way
  • Forgetting that backslashes often need double escaping inside source strings
  • Testing without `g`, then assuming the replacement behavior will still affect every match
  • Misreading multi-line input because `m` and `s` solve different problems

Related developer tools

JSON Formatter

Useful after extracting or cleaning string data and turning it into a structured JSON shape.

URL Parameter Parser

Helpful when you want to inspect query strings and then isolate certain tokens with regex.

Base64 File Encoder

A good companion when you need to inspect encoded strings or strip MIME prefixes with regex.

Frequently Asked Questions

It uses the JavaScript `RegExp` engine available in your current browser. That means syntax and edge cases can differ from PCRE, grep, Python, or Java.
Yes. If your browser supports `(?<name>...)`, named groups will be parsed and displayed in the match results.
That is how JavaScript regex works. Without `g`, matching and replacement focus on the first result only, and this tester mirrors that behavior.
No. Pattern compilation, matching, and replacement preview all happen locally in your browser.