Regex Tester & Debugger

Test and debug JavaScript regular expressions locally in your browser.

No uploadsNo sign-upInstant results
Flags g · i · m · s · u · v · yCapture & Named Groups + Replace100% Local • Zero Uploads
Test Regular Expression
Offline engine ready100% private in-browser workspace • Zero cloud uploads
100% Private • Zero Server File Uploads

Why Use Utiliome's Free Regex Tester & Debugger?

Built from the ground up for strict privacy, instant execution, and zero friction. No subscriptions, paywalls, or account registrations required.

Native ECMA-262 RegExp Parity

Executes directly against your browser's ECMAScript regular expression engine with instant flag toggling for global (g), case-insensitive (i), multiline (m), dotAll (s), Unicode (u), and sticky (y) modes.

Indexed & Named Capture Inspector

Extracts zero-based [start, end) UTF-16 code-unit spans, numbered submatches ($1 through $99), and named capture dictionaries ((?<name>...)) for every match across multi-line payloads.

Live Substitution & Backreference Preview

Evaluates String.prototype.replace and replaceAll templates in real time using $1, $<name>, $& (full match), $' (post-match suffix), and $$ literal dollar escape tokens.

ReDoS Awareness & Zero-Upload Privacy

Highlights nested-quantifier constructs prone to catastrophic backtracking while keeping sensitive production logs, bearer tokens, and customer PII strictly in local browser memory.

Utiliome vs Traditional Cloud Alternatives

Compare our local-first WebAssembly engine against legacy cloud tools.

Feature Utiliome (Local Browser) Legacy Cloud Converters
Execution Safety & ReDoS Protection Runs with step/timeout protection so catastrophic backtracking never freezes your tab Executes on the main UI thread and locks up the browser on nested quantifiers
Capture Group & Named Group Inspector Color-coded inline match highlights plus structured table of $1..$n & (?<name>) Highlights full matches only without inspecting sub-group spans or indices
Live Substitution (replace) Preview Test replacement patterns with $1, $<name>, $&, and flags (g, i, m, s, u, d) Match testing only with no string replacement preview
Private Log & PII Testing 100% client-side evaluation — test against production logs and PII with zero uploads Saves shared/tested regular expressions and sample text in cloud databases
How it works

How to Use Regex Tester & Debugger in 3 Easy Steps

No software installation required. Everything runs directly inside your web browser.

1

Enter Pattern and Toggle Engine Flags

Type your regular expression body without surrounding slashes and enable the exact ECMAScript flags (g, i, m, s, u, y) used by your target JavaScript or TypeScript runtime.

2

Paste Sample Input and Inspect Captures

Paste test strings or load a local log file to inspect highlighted match boundaries, character index spans, numbered capture slots, and (?<name>...) group mappings.

3

Preview Substitutions and Copy Expression

Enter an optional replacement string with $1, $<name>, or $& references to verify transformed text live, then copy your validated regex literal.

Debugging Structured Logs with Named Capture Groups and Live Substitutions

Quick Answer: Combine named capture groups ((?<name>...)) with the global (g) and multiline (m) flags to parse structured log lines into key-value dictionaries, verify exact UTF-16 match offsets, and preview $<name> string transformations before shipping application code.

When troubleshooting regular expressions against multi-line telemetry or access logs, subtle anchor or quantifier mistakes often cause silent non-matches or shifted numbered groups. Consider two structured application log lines containing ISO-8601 timestamps, severity tags, service identifiers, 16-hex-character trace IDs, HTTP status codes, and floating-point latencies:

2026-11-01T14:22:08.419Z [ERROR] svc=checkout trace_id=4bf92f3577b34da6 status=502 latency_ms=184.7
2026-11-01T14:22:09.004Z [INFO] svc=inventory trace_id=00f067aa0ba902b7 status=200 latency_ms=12.3

To parse every line deterministically without fragile positional array indexing, bind each field with an ECMAScript named capture group ((?<name>...)), wrap the optional fractional millisecond suffix in a non-capturing group ((?:...)), and enable both g (global iteration) and m (per-line ^ and $ anchors):

^(?<ts>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\s+\[(?<level>ERROR|WARN|INFO)\]\s+svc=(?<service>[a-z0-9_-]+)\s+trace_id=(?<trace>[0-9a-f]{16})\s+status=(?<status>\d{3})\s+latency_ms=(?<ms>\d+(?:\.\d+)?)$

Without the m flag, ^ and $ anchor exclusively to index 0 and the end of the entire buffer, causing the expression to fail as soon as a newline (\n) separates records. With gm active, the capture group debugger resolves each match iteration into both 1-based positional submatches and a structured groups object:

{
  "matchIndex": 0,
  "span": [0, 99],
  "fullMatch": "2026-11-01T14:22:08.419Z [ERROR] svc=checkout trace_id=4bf92f3577b34da6 status=502 latency_ms=184.7",
  "captures": [
    "2026-11-01T14:22:08.419Z",
    "ERROR",
    "checkout",
    "4bf92f3577b34da6",
    "502",
    "184.7"
  ],
  "groups": {
    "ts": "2026-11-01T14:22:08.419Z",
    "level": "ERROR",
    "service": "checkout",
    "trace": "4bf92f3577b34da6",
    "status": "502",
    "ms": "184.7"
  }
}

Once capture boundaries are verified, you can test String.prototype.replaceAll formatting directly in the substitution panel. Supplying the template [$<level>] $<service>: HTTP $<status> ($<ms>ms, trace=$<trace>) produces normalized output immediately:

[ERROR] checkout: HTTP 502 (184.7ms, trace=4bf92f3577b34da6)
[INFO] inventory: HTTP 200 (12.3ms, trace=00f067aa0ba902b7)

ECMA-262 RegExp Engine Semantics, Flag Mechanics, and Catastrophic Backtracking

Quick Answer: JavaScript regular expressions execute on a backtracking NFA defined by ECMA-262 Section 22.2, operating on 16-bit UTF-16 code units unless the u flag enables full Unicode scalar matching. Avoiding ambiguous nested quantifiers prevents exponential O(2^n) ReDoS execution stalls.

Backtracking NFA Execution and Stateful `lastIndex`

Unlike pure Deterministic Finite Automata (DFA) engines, ECMAScript engines (V8 Irregexp, JavaScriptCore Yarr, SpiderMonkey) implement a backtracking Nondeterministic Finite Automaton (NFA) to support backreferences (\1, \k<name>) and arbitrary lookaround assertions ((?=...), (?!...), (?<=...), (?<!...)). Alternatives separated by | are evaluated left-to-right; greedy quantifiers (*, +, ?, {m,n}) consume as many characters as possible before backtracking step-by-step to satisfy downstream tokens, while reluctant quantifiers (*?, +?, ??, {m,n}?) try the shortest expansion first.

When g (global) or y (sticky) is set, RegExp.prototype.exec() reads and mutates the instance's lastIndex property:

  • Global (g): Searches at or after lastIndex, advancing lastIndex to the end offset of each match (or incrementing by one Unicode code point on zero-length matches) and resetting to 0 upon failure.
  • Sticky (y): Anchors matching strictly at lastIndex without scanning ahead. If no match begins at lastIndex, matching fails immediately and resets lastIndex to 0, making y ideal for building zero-copy lexical scanners.

Line Terminators, UTF-16 Surrogates, and the `u` Flag

ECMA-262 recognizes exactly four line terminator code points: \n (U+000A), \r (U+000D), Line Separator (U+2028), and Paragraph Separator (U+2029). Enabling m makes ^ and $ match boundaries adjacent to those four code points; enabling s (dotAll) allows . to match them.

By default, JavaScript strings are indexed as sequences of 16-bit UTF-16 code units. Supplementary Unicode characters above U+FFFF (such as emoji or mathematical symbols) occupy a two-unit surrogate pair (0xD800–0xDBFF high surrogate followed by 0xDC00–0xDFFF low surrogate). Without u, /^.$/.test("🚀") evaluates to false because "🚀".length is 2. Enabling u switches matching to 21-bit Unicode scalar values, unlocks Unicode property escapes (\p{Letter}, \p{Script=Latin}, \P{Control}), and disables legacy Annex B permissive identity escapes so invalid escapes fail fast at compile time.

ECMA-262 `GetSubstitution` Replacement Grammar

Live replacement follows the standard GetSubstitution table:

  • $$: Inserts a single literal $ character.
  • $&: Inserts the entire matched substring (match[0]).
  • $': Inserts the substring following the matched span.
  • $n / $nn: Inserts 1-indexed numbered capture n (1 through 99).
  • $<name>: Inserts the captured string for (?<name>...), or an empty string "" when the named group did not participate in the current match branch.

Catastrophic Backtracking (ReDoS) Prevention

Regular Expression Denial of Service (ReDoS) arises when nested or overlapping quantifiers—such as (a+)+$, ([a-zA-Z0-9]+\s?)*$, or (.*a){12}—match identical substrings through exponentially many partitions (O(2^n) steps) before failing on a trailing character. Because ECMA-262 omits possessive quantifiers (++) and atomic groups ((?>...)), harden patterns by:

  1. Mutually Exclusive Character Sets: Replace greedy .* between delimiters with negated classes like [^,\r\n]* so the engine cannot cross delimiter boundaries.
  2. Delimiter Unrolling: Rewrite ^(\w+-?)+$ (ambiguous when - is absent) as ^\w+(?:-\w+)*$, reducing worst-case complexity to strictly linear O(n).
  3. Lookahead Atomic Emulation: Where backtracking into a subexpression must be forbidden, capture inside a positive lookahead and consume via an immediate backreference: (?=(\w+))\1.

Regex Tester vs Regex Pattern Generator: Which One Do You Need?

Quick Answer: Use Regex Tester & Debugger when you already have a pattern and need to inspect match offsets, debug named capture groups, toggle ECMAScript flags, or test $<name> string replacements against real payloads. Use Regex Pattern Generator when assembling a new expression visually or exporting multi-language regex code.

Although testing and synthesis belong to the same regular expression workflow, they solve distinct engineering problems. Regex Tester & Debugger is an interactive diagnostic workbench for inspecting how an existing ECMAScript pattern behaves against messy real-world inputs. If instead you need to compose a new expression from visual building blocks, start from an RFC-aligned preset, or export escaped boilerplate for Python, Go, or Rust, switch to Regex Pattern Generator.

Capability Regex Tester & Debugger Regex Pattern Generator
Primary Engineering Task Debug matches, capture spans, flags, and replacements on existing patterns Visually construct new patterns from blocks or verified RFC presets
Starting Input Raw regex expression, ECMAScript flags, and multi-line test text or logs Composable token blocks or developer recipes (UUID, SemVer, IPv4, ISO-8601)
Capture Group Debugging Full [start, end) offset spans, $1–$99 array slots, and (?<name>...) dictionary Positive and negative test fixture pass/fail validation
Live String Substitution Real-time replace / replaceAll preview with $1, $<name>, $&, and $$ Not focused on text transformation templates
Multi-Language Code Export ECMAScript / JavaScript regex literal and pattern output Idiomatic snippets for JavaScript, Python (re), Go (regexp), and Rust (regex)
Engine Architecture Focus Native ECMA-262 backtracking NFA semantics and ReDoS detection Cross-engine portability across ECMA-262, Python re, and linear-time RE2

Recommended Workflow

Start in Regex Pattern Generator when scaffolding validation rules for structured identifiers like semantic versions, RFC 9562 UUIDs, or URL slugs across polyglot services. Once a pattern is deployed in a frontend or Node.js pipeline—or whenever an expression unexpectedly misses an edge case in production logs—paste the expression and raw log sample here in Regex Tester & Debugger to inspect per-match character spans, lastIndex flag interactions, and substitution templates.

FAQ

Regex Tester & Debugger FAQ and Technical Guide

Everything you need to know about using Utiliome's free online regex tester.

Why does a global regex return alternating true and false results with RegExp.prototype.test() in JavaScript?

When the global (g) or sticky (y) flag is set on a JavaScript RegExp object, calling .test() or .exec() mutates the instance's lastIndex property to point immediately after the matched substring. The next .test() call resumes scanning from lastIndex rather than index 0; once it reaches the end of the string without another match, it returns false and resets lastIndex back to 0. For stateless boolean validation, omit the g flag or reset regex.lastIndex = 0 explicitly.

What is the difference between indexed capture groups, non-capturing groups, and named capture groups?

Standard parentheses (...) store matched substrings in sequential 1-based capture slots ($1, $2) and the array returned by exec(). Non-capturing groups (?:...) group tokens for quantifiers or alternation without recording a submatch or shifting downstream $n indices. Named capture groups (?<name>...) populate both their sequential numbered slot and match.groups.name (accessible as $<name> in replacement strings), preventing index breakage when patterns evolve.

When should I enable the Unicode (u) flag in ECMAScript regular expressions?

Enable u whenever matching non-ASCII user text, emoji, CJK supplementary ideographs, or Unicode character categories. Without u, JavaScript evaluates strings as 16-bit UTF-16 code units, causing . or negated classes like [^x] to split 4-byte surrogate pairs above U+FFFF into corrupted half-surrogates. Turning on u switches matching to full 21-bit Unicode code points, enables \p{...} property escapes such as \p{Letter} and \p{Number}, and enforces strict syntax validation on unrecognized escapes.

How do replacement tokens like $&, $1, and $<name> work in live substitution previews?

Substitution previews implement the ECMA-262 GetSubstitution algorithm used by String.prototype.replace() and replaceAll(). $& inserts the entire matched substring, $1 through $99 insert the corresponding numbered capture group, $<name> inserts the text captured by (?<name>...), $' inserts everything after the match, dollar-backtick inserts everything before the match, and $$ outputs a literal $ character.

What causes catastrophic backtracking (ReDoS) and how can I rewrite vulnerable patterns?

Catastrophic backtracking happens in backtracking NFA engines when nested or overlapping quantifiers—such as (a+)+b or ^([a-zA-Z0-9]+\s?)*$—can partition the same input sequence in O(2^n) ways before failing on an unexpected trailing character. Eliminate ambiguity by replacing greedy .* spans with negated character classes ([^,\r\n]*), unrolling optional separators into ^[a-zA-Z0-9]+(?:\s[a-zA-Z0-9]+)*$, and bounding open quantifiers with explicit limits ({1,64}). To build linear-time RE2-compatible patterns from scratch, use Regex Pattern Generator.