ECMAScript RegEx
Coding

RegEx Sandbox & Tester

200ms ReDoS Guard
Regular Expression Pattern
/
Flags:/g/
0.15ms•3 matches

Test Corpus

1663 chars • 37 lines
Match #1Offset: 177..247 (70 chars)
https://privautils.com/coding/regex-tester?utm_source=docs&active=true
Numbered Groups:
$1:https
$2:privautils.com
$3:empty
$4:/coding/regex-tester
$5:?utm_source=docs&active=true
Named Groups:
?<protocol>:https
?<domain>:privautils.com
?<port>:empty
?<path>:/coding/regex-tester
?<query>:?utm_source=docs&active=true
Match #2Offset: 275..327 (52 chars)
https://api.privautils.com:8443/v1/health?check=deep
Numbered Groups:
$1:https
$2:api.privautils.com
$3::8443
$4:/v1/health
$5:?check=deep
Named Groups:
?<protocol>:https
?<domain>:api.privautils.com
?<port>::8443
?<path>:/v1/health
?<query>:?check=deep
Match #3Offset: 1508..1530 (22 chars)
https://privautils.com
Numbered Groups:
$1:https
$2:privautils.com
$3:empty
$4:empty
$5:empty
Named Groups:
?<protocol>:https
?<domain>:privautils.com
?<port>:empty
?<path>:empty
?<query>:empty
Captured: 3 matches
Feature Comparison & Architectural Audit

How PrivaUtils Compares to regex101, RegExr, W3Schools, Coddy & OpenReplay

Standard web regex testers frequently freeze tabs on catastrophic backtracking, send test strings over third-party analytics, or lack structured code generation. Here is a verified feature comparison:

Capability / FeaturePrivaUtilsregex101RegExrW3SchoolsOpenReplay
ReDoS Watchdog Abort Guard200ms Auto-AbortDebugger Step LimitFreezes TabFreezes TabFreezes Tab
Zero-Knowledge In-Browser Privacy100% Local RAMServer API OptionLocal BrowserAd / Tracking NetworkLocal Browser
Resizable Multi-Line Pattern InputYes (Resizable Textarea)YesSingle BarNoNo
Plain-English AST Token ExplainerYes (Categorized AST)Yes (Deep Grammar)Hover Hints OnlyNoNo
Live Substitution & BackreferencesYes ($1, $&, $<name>)YesYesNoNo
Multi-Language Code Generation7 Languages (JS, Py, Go, PHP, Java, Rust, C#)Code Generator DrawerJS OnlyNoNo
Full Screen Distraction-Free WorkspaceYes (100dvh Modal Mode)NoNoNoNo
IndexedDB Settings VaultYes (Export, Import, Revisit)Cloud AccountNoNoNo
ECMAScript Standards & Algorithmic Safety

Mastering Regular Expressions: Engine Mechanics, Named Groups, and ReDoS Safeguards

Regular expressions provide a formal algebraic notation for lexical tokenization and string matching. Standardized in ECMA-262 §22.2, JavaScript's RegExp engine uses a Non-deterministic Finite Automaton (NFA) with backtracking. While NFAs handle lookaround assertions and backreferences efficiently, ambiguous nested quantifiers can trigger exponential time degradation.

1. Pattern Compilation

AST Construction

The engine compiles string patterns into an internal Abstract Syntax Tree (AST), checking character classes, matching bracket pairs, and anchoring boundaries (^ and $).

2. NFA State Traversal

Greedy vs Lazy Evaluation

The automaton consumes characters sequentially. Greedy quantifiers (+, *) match as much text as possible, whereas lazy operators (+?, *?) expand only as needed.

3. ReDoS Guard Sandbox

200ms Watchdog Controller

To protect developer environments from browser thread locking, PrivaUtils monitors execution using high-resolution performance timers, aborting evaluations that exceed the 200ms boundary.

The Mathematics of Catastrophic Backtracking (ReDoS)

Catastrophic backtracking arises when an NFA engine attempts to match an ambiguous regular expression against a payload that fails to match at the final character. Consider the canonical evil pattern:

// Catastrophic Backtracking Pattern
Pattern: /(a+)+$/
Corpus: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!"

For an input consisting of n repetitions of 'a' followed by '!', there are 2n-1 ways to partition characters into nested 'a+' groups. The engine tests each permutation before concluding the string does not match due to the trailing exclamation mark. At n = 30, this requires over 536,000,000 steps; at n = 50, the operations exceed 1015, freezing a single CPU core.

PrivaUtils bounds this behavior by terminating operations after 200ms, displaying collected matches up to that point without freezing user interaction.

Modern ECMAScript RegEx Features: Named Captures and Lookaround Assertions

PrivaUtils supports the modern ECMAScript regular expression specification:

Named Capture Groups (?<name>...)

Instead of referencing captured segments by numeric indices like match[1], named groups assign explicit semantic identifiers accessible via match.groups.name.

/(?<year>\d{4})-(?<month>\d{2})/
Lookbehind Assertions (?<=...) & (?<!...)

Positive and negative lookbehinds match tokens only when immediately preceded by another pattern, without including the preceding characters in the match result.

/(?<=\$)\d+(\.\d{2})?/ // Matches USD currency

RegEx Flag Reference: g, i, m, s, u, y, v

FlagNameStandardDescription
gGlobalES3Matches all occurrences across the corpus rather than halting at the first match.
iInsensitiveES3Case-insensitive matching (A matches a).
mMultilineES3^ and $ match the beginning and end of each line, not just the entire input string.
sDotAllES2018Allows the dot (.) metacharacter to match newline characters (\n, \r).
uUnicodeES2015Treats the pattern as a sequence of Unicode code points, handling surrogate pairs.
yStickyES2015Matches only from the index specified by regex.lastIndex.
vUnicode SetsES2024Enables set operations (difference, intersection) and Unicode properties of strings.

Frequently Asked Questions (FAQ)

What happens when a regex evaluation times out?

When matching exceeds 200ms, PrivaUtils stops the execution and displays an alert. Matches gathered prior to the timeout limit remain visible in the inspector so you can diagnose the bottleneck.

Are test strings or private tokens transmitted to a server?

No. All evaluations occur in browser memory. No tokens, production logs, or test data are transmitted to remote APIs.

How does the substitution preview handle backreferences?

The Replace tab evaluates standard replacement tokens such as $1, $& (the matched text), and named capture references like $<groupName> in real time.

How does PrivaUtils save tool settings?

Preferences including default flags, multiline editor style, highlight theme, and ReDoS timeout limits are saved to browser IndexedDB under the regex-tester-settings key. You can view, export, import, or clear these settings in the Storage Vault modal.

Related Privacy Utilities

Peer tools running locally in your browser memory without server uploads.

Explore all utilities