RegExp Tester & Debugger

Test regular expression patterns and flags with live match highlighting, capture group tables, replace preview, and ReDoS timeout protection.

Live Highlight · Capture Groups · ReDoS Safe

Loading tool workspace...

Overview of the Online Regular Expression (RegExp) Tester

From validating user sign-up inputs and parsing unstructured server logs to refactoring source code across hundreds of files, Regular Expressions (RegExp) are one of the highest-leverage tools in software development. Yet a single misplaced quantifier (+, *, ?) or unescaped metacharacter can silently over-match production data—or trigger exponential backtracking that freezes a Node.js event loop or browser tab.

AllUtility’s Regex Tester executes every pattern inside an isolated inline Blob Web Worker rather than blocking the main UI thread. Featuring real-time canvas match highlighting, full capture-group inspection tables, live string replacement (Replace) previews, and one-click validation presets, every test runs 100% locally in your browser with complete data privacy.

Web Worker ReDoS Protection & Core Features

JavaScript’s RegExp engine uses a Nondeterministic Finite Automaton (NFA) backtracking matcher. Pathological patterns with nested quantifiers—such as (a+)+$ evaluated against a long non-matching string—trigger Catastrophic Backtracking (ReDoS), spiking CPU usage to 100%. Our tester dispatches evaluation to a dedicated background worker supervised by a strict 1000ms watchdog timer: if a pattern hangs, the worker is immediately terminated (worker.terminate()) and respawned cleanly while keeping your editor responsive.

  • Full JS Flag Controls (g, i, m, s, u) & Timing (ms): Toggle global (g), case-insensitive (i), multiline anchors (m), dotAll newline matching (s), and Unicode code-point (u) flags while monitoring exact execution time in milliseconds.
  • Live Match Highlighting & Capture Group Matrix: Inspect match counts, character index offsets, full match strings, numbered capture groups (1..N), and named groups entries in a structured table.
  • Real-Time Replace Preview: Test substitution templates using $1, $2, and $& backreferences live without mutating your original sample text.
  • 6 One-Click Practical Presets: Load battle-tested patterns for Email, Web URL, Mobile Phone, IPv4 Address, HEX Color, and ISO 8601 Date (YYYY-MM-DD) instantly.

Step-by-Step Usage Guide

  1. Enter Pattern & Flags: Type your regular expression pattern (without surrounding slashes) or load one of the quick presets, then toggle the desired flags (g, i, m, s, u).
  2. Paste Sample Text: Drop log lines, JSON snippets, or form inputs into the test text area to highlight every matching span and measure elapsed ms immediately.
  3. Inspect the Capture Matrix: Check the breakdown table below the canvas to verify start/end indices and ensure each parenthesized group ( ... ) extracts the exact substring you expect.
  4. Preview Replacements & Copy: Enter a replacement string (such as $1-$2) to verify transformed text in real time, then copy the verified pattern or output directly into your codebase.

Practical Substitution Example & Optimization Tips

Combining numbered capture groups with backreferences turns tedious multi-line string parsing into a single declarative pass:

Regex Pattern      : (\d{4})-(\d{2})-(\d{2})   [Flags: g]
Sample Input       : Start: 2026-05-01, Renewal: 2027-04-30
Replacement Format : $2/$3/$1
Replaced Output    : Start: 05/01/2026, Renewal: 04/30/2027
  • Prefer Negated Character Classes ([^"]+) Over Greedy .*: Matching quoted text with ".*" greedily consumes everything from the very first quote to the final quote on the line. Writing "[^"]*" is not only accurate—it eliminates backtracking overhead altogether.
  • Use Non-Capturing Groups ((?:...)) When Grouping Only: Whenever parentheses are only needed for alternation ((?:jpg|png|webp)) or repetition rather than data extraction, prefix with ?: to keep capture indices clean and reduce memory allocation.

Frequently Asked Questions

Why is my regular expression stopping after the very first match?

Make sure the g (global) flag is enabled. Without g, JavaScript's RegExp matcher returns only the first occurrence in the input string and halts. Turning on g instructs the engine to iterate through every non-overlapping match across the entire text.

What does the 1000ms timeout warning mean when testing a complex pattern?

It means your expression hit catastrophic backtracking (ReDoS) on the sample input—almost always caused by nested or overlapping quantifiers like (a+)+ or ([a-zA-Z]+)*. Catching a timeout here saves you from deploying a regular expression that could stall a production server under malicious input.

When do I need the m (multiline) and u (unicode) flags?

Enable m (multiline) when working with 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. Enable u (unicode) whenever matching astral-plane emojis or Unicode script properties (\p{L}) so surrogate pairs are treated as whole characters.

Are confidential log snippets or proprietary patterns sent to any server?

Never. Both the UI and the Blob Web Worker run 100% locally inside your browser's memory sandbox with zero network requests, making it completely safe for debugging production logs and internal validation rules.