Skip to main content
DigiToolBay
Developer ToolsClient-Side Browser Processing

Regex Tester

Test ECMAScript regular expressions with match highlighting, capture group inspection, and replace preview.

Loading Regex Tester...

Evaluates ECMAScript RegExp locally in your browser.

By DigiToolBay Editorial TeamPublished & verified:

About Regex Tester: Guide & Practical Notes

Regular expressions behave differently across JavaScript, Python, and PCRE—and small flag mistakes (like missing `g` or `m`) can silently break form validation or search-and-replace scripts.

Evaluates standard ECMAScript `RegExp` patterns against test strings locally, listing match indices, captured groups (`$1`, `$2`, ...), and optional `String.replace()` output.

How to Use Regex Tester Step by Step

  1. Enter your Regular Expression pattern (without outer `/slashes/`) and Flags (such as `g`, `i`, `m`, `s`, `u`).
  2. Paste sample lines or log text into Test String.
  3. Optionally enter a Replacement pattern (like `[$1]`) to preview transformations.

Worked Example

Extract username and domain from email addresses.

Inputs: Pattern: ([a-z0-9._-]+)@([a-z0-9.-]+\.[a-z]{2,}) | Flags: gi | Text: "Contact hello@digitoolbay.com"

Result: Match #1 @ index 8: "hello@digitoolbay.com" | $1="hello", $2="digitoolbay.com"

Parentheses create capture groups `$1` and `$2`, while `g` finds every occurrence and `i` ignores letter casing.

ECMAScript RegExp Engine & ReDoS Caveats

Runs using your browser’s native JavaScript `RegExp` engine. Note that JS regex lacks certain PCRE features like possessive quantifiers (`++`) or atomic groups, and deeply nested ambiguous quantifiers like `(a+)+$` can cause catastrophic backtracking (ReDoS) on adversarial non-matching input.

Common Real-World Uses

  • Testing email, slug, or invoice-number validation patterns before shipping JS code
  • Extracting structured tokens and capture groups from pasted server logs
  • Previewing batch find-and-replace rules safely

Common Mistakes to Avoid

  • Forgetting the `g` (global) flag and wondering why only the first occurrence matches.
  • Forgetting to escape literal dots `\.` (which otherwise match any character).

Supported Formats, Scope & Limitations

Caps displayed match listings at 500 matches per run to keep browser rendering snappy on large pastes. Avoid nested quantifiers on untrusted inputs.

Privacy & Local Processing

Patterns and sample logs stay strictly inside your browser.

Frequently Asked Questions

What do the flags g, i, m, s, and u mean?

`g` finds all matches, `i` ignores case, `m` makes `^`/`$` match line boundaries, `s` (dotAll) lets `.` match newlines, and `u` enables full Unicode mode.

Why did my regex match differently in PHP/Python vs. here?

This tool runs the standard JavaScript ECMAScript regex flavor, which differs slightly from PCRE and Python `re`.

Comparing log lines before and after cleanup? Try the Text Diff Checker.