100% Free & Client-Side: All 92 tools run locally inside your browser — zero server uploads, zero signups.
Developer Tools100% Free • Runs in Your Browser • No Upload

Real-Time Regular Expression Tester & Capture Group Debugger

Test regular expressions live with highlighted matches, capture group inspection (`$1`, named groups), flag toggles, and presets.

100% Client-Side Privacy
Instant Browser Processing
Presets:
//gm
Contact support@example.com or sales.team@sub.domain.org for details.
Capture Groups & Match Breakdown (2)
Match #1 (index 8..27): “support@example.com”
Group $1: “support”Group $2: “example.com”
Match #2 (index 31..56): “sales.team@sub.domain.org”
Group $1: “sales.team”Group $2: “sub.domain.org”
Overview & Introduction

What is the Regex Tester & Debugger?

The Regex Tester & Debugger is an interactive regular expression workbench that evaluates ECMAScript / JavaScript patterns against your test strings in real time. Writing regular expressions for input validation, log parsing, URL routing, or search-and-replace refactors is famously error-prone—a single misplaced quantifier or unescaped bracket can cause a pattern to miss edge cases or greedily consume an entire line.

As you type your regular expression pattern and toggle flags (`g` global, `i` case-insensitive, `m` multiline, `s` dotAll, `u` unicode), the workspace immediately highlights every match inside the visual preview canvas using alternating color badges so even adjacent matches remain clearly distinguishable. Below the canvas, a comprehensive Capture Groups & Match Inspector Table lists every match index, exact character span (`start..end`), full matched substring (`$0`), numbered capture groups (`$1`, `$2`, ...), and ES2018 Named Capture Groups (`(?<name>...)`).

To accelerate your workflow, the tool also includes a Live Replace / Substitution Previewer (supporting `$1`, `$&`, and `$<name>` backreferences) plus one-click Cheat-Sheet Presets for Email Addresses, HTTP/HTTPS URLs, IPv4 Addresses, Hex Color Codes, and ISO Dates.

Step-By-Step Instructions

How to Use Regex Tester & Debugger (Step-by-Step)

  1. 1

    Enter Your Regular Expression Pattern

    Type your regex pattern into the `/pattern/` input bar (without surrounding slashes), or click one of the Quick Presets (Email, URL, IPv4, Hex Color, Date) to load a tested pattern.

  2. 2

    Toggle Regex Flags (g, i, m, s, u)

    Click the flag chips to toggle Global (`g`), Case-Insensitive (`i`), Multiline (`m`), DotAll (`s`), or Unicode (`u`) evaluation modes.

  3. 3

    Paste Your Test String & View Highlighted Matches

    Enter multi-line sample text into the Test String editor and watch the Highlighted Match Preview mark every match with its index and span.

  4. 4

    Inspect Capture Groups & Named Groups

    Scroll to the Match & Capture Group Breakdown list to inspect each match's character position, numbered groups (`Group 1`, `Group 2`), and named capture groups.

  5. 5

    Test Regex Replacement (Optional)

    Open the Replace tab and enter a replacement template (such as `$2-$1` or `[REDACTED]`) to preview `String.prototype.replace()` output live.

Core Capabilities

Key Features of Our Regex Tester & Debugger

Live Color-Coded Match Highlighting

Highlights every matched substring in real time with alternating color tokens so adjacent matches are easy to spot.

Numbered & Named Capture Group Inspector

Displays full match (`$0`), numbered capture groups (`$1`, `$2`...), named groups (`(?<year>...)`), and exact start/end indices.

Interactive Flag Toggles (g, i, m, s, u)

One-click toggles for Global, Case-Insensitive, Multiline (`^`/`$`), DotAll (`.` matches `\n`), and Unicode flags.

One-Click Pattern Presets

Instant tested presets for Email, URL, IPv4 Address, Hex Color (`#RGB`/`#RRGGBB`), and ISO 8601 Date (`YYYY-MM-DD`) with sample test strings.

Live Backreference Replace Preview

Test `string.replace(regex, replacement)` live using `$1`, `$2`, `$&`, and `$<name>` substitution syntax.

Built-In Regex Syntax Quick Reference

Handy cheat-sheet covering character classes (`\d`, `\w`, `\s`), quantifiers (`+`, `*`, `{n,m}`, `+?`), anchors, and lookarounds.

Key Benefits & Advantages

Eliminate Trial-and-Error Console Logging

See immediately how greedy (`.*`) versus lazy (`.*?`) quantifiers affect match boundaries across multi-line text.

Verify Capture Group Indexing Before Coding

Confirm which parentheses produce `$1`, `$2`, or non-capturing `(?:...)` groups before writing `match[1]` in your production code.

Instant Syntax Error Feedback

Unclosed character classes, invalid quantifiers, or bad group names display a clear syntax error message instead of crashing.

100% Private Local Log & Data Testing

Test regex patterns against real server logs, customer emails, or proprietary source code without sending data to external servers.

Who Is This For?

Common Real-World Use Cases

Form Input Validation Rules

Craft and test patterns for usernames, postal codes, phone numbers, password complexity, and custom product SKUs.

Server Log & Stack Trace Parsing

Extract timestamps, IP addresses, HTTP status codes, and latency metrics from Nginx, Apache, or application log lines.

IDE Search-and-Replace Refactoring

Build and preview capture-group replacement templates (`$1`, `$2`) before running bulk regex replacements in VS Code.

Web Scraping & Data Extraction

Design non-greedy patterns and lookaheads (`(?=...)`) to pull structured values out of unstructured text documents.

Under The Hood

How Regex Tester & Debugger Works Technically

Under the hood, our Regex Tester instantiates a native ECMAScript `RegExp(pattern, flags)` object inside a safe `try / catch` harness. When the `g` (global) flag is active, the engine iterates over the test corpus using `RegExp.prototype.exec(testString)` in a bounded loop. To prevent catastrophic infinite loops when a pattern matches a zero-length substring (such as `/a*/g` or `/^/gm`), the runner checks whether `match[0].length === 0` on each iteration and manually advances `regex.lastIndex++` by one UTF-16 code unit, matching the exact behavior of `String.prototype.matchAll()`.

To render the color-coded highlight canvas without exposing the DOM to Cross-Site Scripting (XSS) when testing HTML snippets, the test string is sliced into alternating non-match segments and match spans using the exact `[match.index, match.index + match[0].length]` offsets, and each slice is rendered as an escaped React text node inside a styled `<mark>` element.

Best Practices

Expert Tips for Best Results

  • Use non-capturing groups `(?:...)` whenever you need parentheses to group `|` alternatives or apply a quantifier without polluting your `$1, $2` capture group array.
  • By default, quantifiers like `*` and `+` are greedy (matching as much text as possible). Append a question mark (`*?` or `+?`) to make them lazy (matching as little text as possible).
  • Enable the `m` (Multiline) flag when testing multi-line logs so `^` and `$` match the start and end of each individual line rather than only the start and end of the entire string.
  • Use Named Capture Groups `(?<year>\d{4})-(?<month>\d{2})` to make your JavaScript `match.groups.year` code self-documenting.
  • Click any of the 5 preset buttons (Email, URL, IPv4, Hex Color, Date) to load both the regex pattern and a matching sample text corpus in one click.

100% Local Browser Privacy Guarantee

All regular expression compilation and string matching execute locally in your browser's JavaScript engine. Test strings and patterns never leave your device.

Questions & Answers

Frequently Asked Questions About Regex Tester & Debugger

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

`g` (Global) finds all matches rather than stopping after the first match; `i` (Case-Insensitive) ignores uppercase/lowercase differences; `m` (Multiline) makes `^` and `$` match the start and end of every line; `s` (DotAll) allows the dot `.` to match newline characters (`\n`); and `u` (Unicode) enables full Unicode code point matching.

What is the difference between a capturing group (...) and a non-capturing group (?:...)?+

A standard capturing group `(...)` both groups tokens together AND saves the matched text into a numbered slot (`$1`, `$2`, etc.). A non-capturing group `(?:...)` groups tokens for quantifiers or `|` alternation without creating a numbered capture group.

How do Named Capture Groups work in JavaScript?+

Write `(?<name>pattern)` inside your regex—for example, `(?<area>\d{3})-(?<exchange>\d{3})`. In our Capture Groups breakdown (and in JavaScript's `match.groups`), you will see the extracted values labeled directly by name (`area`, `exchange`).

Why is my `.*` pattern matching way too much text?+

The `*` and `+` quantifiers are 'greedy' by default, meaning they match up to the very last occurrence of the following token. Change `.*` to `.*?` (lazy quantifier) so it stops at the very first occurrence instead.

How do I match a literal period (.), question mark (?), or bracket ([)?+

Escape special regex metacharacters (`\ ^ $ . | ? * + ( ) [ ] { }`) by placing a backslash `\` in front of them—for example, `\.` matches a literal period and `\?` matches a literal question mark.

How do I use capture groups in the Replace field?+

In the Replacement string input, use `$1`, `$2`, etc. to insert numbered capture groups, `$&` to insert the entire matched text, or `$<name>` to insert a named capture group.

Recommended Related Tools

More in Developer Tools

View All Developer Tools →