Home
.*
RegexTester

Online Regular Expression Tester & Debugger

ES2024 / ECMAScript

Test, debug, and benchmark regular expressions in real-time with capture group extraction, replacement previews, regex flag toggles, and syntax explanations.

//
Flags:
4 matches•2 capture groups•Execution: 0.05ms
Pattern: Valid

Test String Input

275 characters4 Lines:
Legend: Full Match Group $1 Group $2
Welcome to ToolsAA! For privacy inquiries, contact privacy@toolsaa.com. Support department is reached at support.help+urgent@sub.domain.co.uk. Sales queries: sales-apac@enterprise.org or ceo@startup.io. Invalid formats such as user@ or @domain.com are automatically excluded.

ECMAScript RegEx Engine

Fully compliant with modern JavaScript regular expression specifications including named capture groups, lookbehinds, and unicode property escapes.

Interactive Group Extraction

Inspect matched strings with detailed breakdowns for numbered ($1, $2) and named (?<name>) capture groups alongside match start/end indices.

ReDoS Guarded In-Browser Execution

Evaluation is sandboxed locally with client-side timeout guards to protect against catastrophic backtracking without freezing your session.

Technical Reference & Architecture Guide

Regex Tester Developer Reference

Developer utility for regex-tester.

Quick Summary

Regular expressions match structured text patterns using character classes, quantifiers, lookarounds, and capture groups powered by JavaScript's RegExp engine. Test live highlights across global (`g`), multiline (`m`), case-insensitive (`i`), and dotAll (`s`) flags while guarding against catastrophic backtracking (ReDoS).

Regex Tester Developer Reference — Client-Side In-Memory Architecture & Data Flow
Regex Tester Developer Reference — Client-Side In-Memory Architecture & Data Flow

Key Parameters & Controls

Key Parameters & Controls
ParameterType / UnitDescriptionDefault
patternstring (ECMAScript RegExp pattern)Regular expression pattern syntax supporting character classes, quantifiers, lookaround assertions, numbered groups, and named groups.([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})
flagsArray<"g" | "i" | "m" | "s" | "u" | "y">Engine compilation flags configuring global matching (g), case-insensitive matching (i), multiline line boundaries (m), dotAll newline matching (s), full Unicode surrogate handling (u), and sticky lastIndex matching (y).["g", "i"]
testStringstringTarget text payload evaluated in real time against the compiled regular expression, supporting multiline strings up to 150,000 characters.Welcome to ToolsAA! Contact privacy@toolsaa.com or support@domain.co.uk.
replacePatternstringSubstitution string template supporting group backreferences ($1..$n), named groups ($<name>), full match ($&), preceding prefix ($`), and trailing suffix ($').User: $1 | Domain: $2
activeTab"visual" | "matches" | "replace" | "cheatsheet"Inspection view mode: visual syntax mark highlighting, detailed match index tree and JSON export, live substitution output, or interactive token reference."visual"
highlightMode"groups" | "matches"Visual highlighting granularity selecting whether distinct captured groups receive unique color badges or entire match spans share unified bounding marks."groups"

Pro Tips & Best Practices

Prevent Catastrophic ReDoS

Avoid nested overlapping quantifiers such as (a+)+ or ([a-z]*)* which trigger exponential O(2^n) backtracking on failed matches. Refactor using mutually exclusive character classes (e.g. [^@\s]+) or possessive/atomic structures.

Leverage Named Capture Groups

Use (?<groupName>pattern) to extract self-documenting data models and eliminate fragility caused by numeric index shifting ($1, $2) during schema refactoring.

Sticky Matching for Tokenizers

Activate the 'y' (sticky) flag in combination with RegExp.lastIndex when constructing lexical scanners. Sticky matching enforces assertions strictly at the current cursor without scanning the remainder of the payload.

Export Match Tree as JSON

Switch to the 'Matches' tab and click 'Copy as JSON' to extract structured AST-like payloads including start and end offsets, match substrings, and named group maps directly into test suites.

Common Gotchas & Troubleshooting

⚠️SyntaxError: Invalid regular expression or unescaped slash

Literal forward slashes in URL paths or HTML tags must be escaped with a backslash (\/), or metacharacters can be escaped automatically using the 'Escape' button in the toolbar.

⚠️Execution Timed Out (250ms) Safeguard Triggered

The pattern exceeded the 250ms catastrophic backtracking threshold. Disassemble ambiguous nested quantifiers into strict, deterministic boundaries before re-evaluating.

⚠️Zero-width match causes infinite loop warnings

Patterns matching empty strings (such as ^, $, or a*) advance lastIndex by 1 automatically in global mode. Provide explicit character anchors or positive lookahead constraints to prevent zero-length cycles.

Frequently Asked Questions

Which ECMAScript specification does this regex engine follow?▼

The evaluator executes natively in the host JavaScript V8/SpiderMonkey runtime, strictly adhering to the ECMA-262 specification. It supports ES2018+ features including named capture groups (?<name>...), lookbehind assertions (?<=...), Unicode property escapes \p{...} (with flag u), and match indices (flag d).

How does the tool prevent browser freezes on catastrophic backtracking (ReDoS)?▼

The client evaluation loop employs a three-tier protection architecture: static heuristic pattern analysis for nested repetition, a strict 250ms monotonic execution cutoff via performance.now(), and an iteration ceiling capped at 20,000 passes and 1,500 maximum match records.

Are sensitive logs or tested payloads uploaded to any cloud server?▼

No. In accordance with ToolsAA privacy-first design, all pattern compilation, string scanning, and substitution run entirely in browser memory. No external API endpoints or network sockets are accessed during testing.

What is the maximum payload size supported for input strings?▼

The live engine evaluates strings up to 150,000 characters synchronously. For visual DOM rendering performance, highlight marks are capped at the first 300 matches or 40,000 characters to maintain 60 FPS scrolling, while all matches remain available in the Matches tab.

How do substitution tokens work in the replacement engine?▼

Replacements follow standard ECMAScript String.prototype.replace semantics: $1 through $99 insert numbered capture groups, $<name> inserts named groups, $& inserts the full match, $` inserts preceding text, $' inserts succeeding text, and $$ produces a literal dollar sign.