Regex Tester & Live Debugger
Validate ECMAScript regular expressions in real time with match highlighting, named capture group inspection, flag toggles, and catastrophic backtracking diagnostics.
/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/gReady locally via WebAssembly & JavaScriptMatch #1: engineering@nexuscalculator.net ($1="engineering", $2="nexuscalculator.net")100% Client-Side • Zero Server Upload
Writing a regular expression from memory and shipping it straight to production is a classic source of subtle parsing bugs, dropped log lines, and event-loop stalls. A live debugger lets you verify every boundary condition—anchors, lazy quantifiers, capture groups, and Unicode character classes—against realistic multi-line payloads before committing code.
This Regex Tester & Live Debugger runs 100% client-side inside your browser's native JavaScript engine. Sensitive production log snippets, customer PII samples, auth header formats, and proprietary parsing rules stay strictly in local browser memory with zero network uploads.
ECMAScript RegExp Engine Architecture and Flag Semantics
JavaScript's RegExp engine implements the ECMA-262 Section 22.2 specification using a backtracking Nondeterministic Finite Automaton (NFA). Because the engine attempts paths from left to right and backtracks whenever a branch fails, quantifier order and greediness directly control both match output and runtime latency. Adding ? after *, +, or {m,n} switches from greedy matching (consuming as much as possible first) to lazy matching (expanding only as needed to satisfy the remainder of the pattern).
Modern ECMAScript supports several expressive grouping and assertion primitives. Non-capturing groups (?:...) apply quantifiers or alternations without allocating a capture slot, avoiding unnecessary memory overhead in tight loops. Named capture groups (?<name>...) populate match.groups, making complex parsers resilient to later edits, and can be referenced inside the same pattern via \k<name>. Positive lookaheads (?=...), negative lookaheads (?!...), and ES2018 lookbehinds (?<=...) / (?<!...) assert surrounding context without consuming characters into the matched span—essential when extracting values bounded by delimiters that must not appear in the final token.
Engine flags alter global semantics across the entire automaton: g finds all non-overlapping matches, i applies Unicode case folding, m binds ^ and $ to line boundaries, s (dotAll) allows . to match \n, \r, \u2028, and \u2029, and d (hasIndices) exposes exact start and end character offsets via match.indices for syntax highlighters. Finally, u enables full UTF-16 surrogate pair handling plus Unicode property escapes such as \p{Letter}, while ES2024 v (unicodeSets) adds character-class set subtraction and intersection.
Step-by-Step Walkthrough: Parsing Structured Logs with Named Groups
Suppose you need to extract timestamp, HTTP method, path, and status code from API gateway logs while skipping /healthz readiness probes. Start with a clean anchored pattern using named capture groups and a negative lookahead on the path:
^(?<ts>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)\s+(?<method>GET|POST|PUT|DELETE)\s+(?!\/healthz\b)(?<path>\/\S*)\s+(?<status>[1-5]\d{2})$
Test this against a mixed corpus with the g and m flags enabled:
2026-11-27T09:14:02Z GET /healthz 200
2026-11-27T09:14:05Z POST /v1/invoices/create 201
2026-11-27T09:14:09Z GET /v1/users/42?tab=billing 502
Line 1 is skipped cleanly because (?!\/healthz\b) rejects /healthz right before the path group consumes characters. Notice the \b word boundary inside the negative lookahead: without it, a real endpoint named /healthz-metrics would also be excluded. In JavaScript, String.prototype.matchAll iterates every match safely without mutating external state:
const pattern = /^(?<ts>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)\s+(?<method>GET|POST|PUT|DELETE)\s+(?!\/healthz\b)(?<path>\/\S*)\s+(?<status>[1-5]\d{2})$/gm;
for (const match of logCorpus.matchAll(pattern)) {
const { ts, method, path, status } = match.groups;
console.log({ ts, method, path, status: Number(status) });
}
ECMAScript Regex Syntax and Flag Reference Table
Use this quick reference to verify ECMA-262 constructs and their exact behavior in modern JavaScript runtimes:
| Construct / Flag | Syntax | Engine Behavior | Typical Engineering Use Case |
|---|---|---|---|
| Named Capture | (?<id>...) | Stores match in match.groups.id | Self-documenting log and URL parsers |
| Non-Capturing | (?:...) | Groups tokens without saving capture | Alternations like (?:http|https):// |
| Negative Lookahead | (?!...) | Fails if suffix matches ahead | Excluding paths or reserved keywords |
| Positive Lookbehind | (?<=...) | Asserts prefix without consuming it | Matching amounts after USD |
| Lazy Quantifier | *?, +? | Consumes minimum required characters | Extracting quoted tokens safely |
| Unicode Property | \p{L}, \p{N} | Matches Unicode categories (requires u) | Internationalized name or tag validation |
| Multiline + dotAll | m and s | ^/$ match lines; . matches \n | Parsing multi-line config blocks |
Catastrophic Backtracking (ReDoS), Security, and Edge Cases
The sharpest operational hazard in NFA regex engines is Regular Expression Denial of Service (ReDoS). When a pattern contains nested quantifiers such as ^([a-zA-Z0-9]+)+$ or overlapping alternations like (a|a?)+b, a non-matching string like aaaaaaaaaaaaaaaaaaaaaaaa! forces the engine to explore an exponential number of partitioning combinations before failing. On Node.js, a single malicious request payload can peg a CPU core at 100% and block the entire event loop for seconds or minutes.
Prevent ReDoS with four defensive rules:
- Eliminate nested quantifiers: Collapse
([a-z]+)+to[a-z]+, and replace greedy.*bridges with negated character classes such as[^/]+or[^"]+so the engine cannot over-consume and backtrack. - Make alternations mutually exclusive: Ensure branches inside
(A|B)*cannot match the same starting characters. - Bound input length first: Reject strings exceeding an explicit character ceiling (for example, 4,096 bytes) before invoking
.exec()or.test(). - Watch stateful
gflags: Never share a/gregex literal across.test()calls inside validation middleware becauselastIndexpersists between invocations; omitgfor boolean checks or usematchAll()for iteration. - Consider linear-time engines for untrusted patterns: Because ECMAScript
RegExpuses backtracking rather than a DFA/Thompson NFA engine like Google RE2, never compile user-supplied regex strings directly on your API server without static complexity analysis or isolated worker timeouts. Similarly, remember that stickyymatching anchors strictly tolastIndexwithout scanning forward, which makes it ideal for tokenizers but surprising if accidentally enabled in general search.
How to Use Regex Tester & Live Debugger
Enter your ECMAScript regex pattern without outer slashes and toggle the desired flags.
Paste realistic positive and negative test strings—including edge cases—into the corpus editor.
Inspect highlighted full matches, numbered subgroups, and named group key-value pairs.
Refine quantifiers or anchors if any match overshoots or triggers backtracking warnings.
Real Examples
Extract Email User & Domain
Capture local-part and domain separately.
/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/gMatch #1: engineering@nexuscalculator.net ($1="engineering", $2="nexuscalculator.net")Frequently Asked Questions
Which regex flavor does this tester execute?
What is the difference between the s (dotAll) and m (multiline) flags?
How do named capture groups simplify production JavaScript code?
What causes catastrophic backtracking (ReDoS) in regular expressions?
Why does calling .test() twice on a regex with the g flag alternate true and false?
Key Features
- Live ECMAScript RegExp evaluation with highlighted match spans and indices
- Detailed breakdown of numbered and named capture groups per match
- Interactive toggles for g, i, m, s, u, and y engine flags
- Early detection of nested quantifiers and ReDoS backtracking hazards
- 100% client-side execution with zero log or payload transmission
Common Use Cases
- Extracting structured fields from NGINX, Kubernetes, or JSON-adjacent server logs
- Authoring strict form, slug, and API parameter validation rules in TypeScript
- Debugging why a lookahead or lookbehind assertion fails on multiline input
- Auditing user-facing or untrusted patterns for catastrophic backtracking risk
- Testing Unicode property escapes before deploying internationalized input parsers
Explore More Tools in This Category
View All Developer & Utility ToolsJSON to CSV Converter
Flatten nested JSON objects and arrays into RFC-4180 compliant CSV spreadsheets with configurable delimiters and UTF-8 BOM encoding directly in your browser.
CSV to JSON Converter
Transform RFC-4180 CSV datasets into clean, strongly typed JSON arrays with automatic delimiter detection and number/boolean coercion right in your browser.
JSON to YAML Converter
Convert JSON payloads into clean, human-readable YAML 1.2 manifests with safe string quoting for Kubernetes, Docker Compose, GitHub Actions, and OpenAPI specs.
JSON to TypeScript Interface Generator
Infer clean, recursive TypeScript export interfaces and union array types from raw JSON payloads directly in your browser for end-to-end API type safety.
SQL INSERT to JSON Converter
Parse SQL INSERT INTO ... VALUES statements directly into clean, strongly typed JSON object arrays without a database server.
JSON Formatter & Validator
Format, validate, and minify your JSON data instantly. Our free online JSON Formatter makes your code readable, helps debug syntax errors, and optimizes data for production.
Diff Checker & Text Compare
Compare two text, JSON, or code files instantly to find differences. A fast, local, browser-based diff tool for developers.
HTML Formatter & Beautifier
Format, beautify, and minify your HTML code instantly. Clean up messy HTML tags, detect unclosed elements, and live-preview your code.