Regular Expression Tester & Debugger
Test and debug JavaScript regular expressions in real-time. Features live match visualizer, capture groups inspector, and background Web Worker execution with ReDoS protection. 100% client-side and private.
JavaScript Regular Expression Tester
Test patterns safely in an isolated Web Worker with ReDoS timeout protection. Zero server transmission.
Extracted Match Details (2)
Execution time: 0 msMastering JavaScript Regular Expressions
Understanding ReDoS & Catastrophic Backtracking
Regular Expression Denial of Service (ReDoS) happens when a Non-deterministic Finite Automaton (NFA) regex engine evaluates nested quantifiers on non-matching strings:
- Vulnerable Pattern:
(a+)+$tested againstaaaaaaaaaaaaaaaaaaaaaaaaaaaa!causes O(2n) iterations. - Web Worker Protection: By running the engine in a separate worker thread, our tool isolates CPU spikes and aborts after 2 seconds.
- Atomic & Possessive Thinking: Prevent backtracking by using character classes or lookarounds where appropriate.
Standard ECMAScript Flags Reference
Flags modify how the regex engine traverses and parses the search string:
- g (Global): Retains search position and matches all occurrences instead of only the first.
- i (Ignore Case): Matches letters without regard to capitalization.
- m (Multiline): Anchors
^and$match beginning and end of each line. - s (DotAll): Allows wildcard
.to match newline characters (\n). - u (Unicode): Treats characters as full 21-bit Unicode code points rather than 16-bit UTF-16 code units.
Frequently Asked Questions
How does this Regex Tester protect against catastrophic backtracking (ReDoS)?
User regular expressions are executed inside an isolated background Web Worker thread rather than the browser's main UI thread. A strict 2,000-millisecond execution deadline is enforced by the main thread. If an exponential backtracking pattern stalls the worker, the thread is forcefully terminated, keeping your browser tabs smooth and completely responsive.
What JavaScript regex flags are supported?
All standard ECMAScript flags are supported: 'g' (global matching), 'i' (case-insensitive), 'm' (multiline anchors), 's' (dotAll), 'u' (Unicode code points), 'y' (sticky matching), 'd' (match indices), and 'v' (extended Unicode sets). Per the ECMAScript standard, 'u' and 'v' cannot be used simultaneously.
Does this tool support named capture groups?
Yes. Patterns using syntax like '(?<name>pattern)' will automatically extract and display named capture groups in the match breakdown inspector alongside standard numbered groups ($1, $2).
Are my test strings or patterns sent to any server?
No. All regular expression compilation and matching occur 100% client-side in your local browser. No data, search queries, or text inputs are transmitted over the network or logged.
How does the tool handle zero-length matches like /^/gm or /a*/g?
Patterns that match empty strings can cause infinite loops in naive implementations. This engine automatically advances the regex search index past zero-length matches (with surrogate-pair awareness for emoji and Unicode characters) to extract all valid match locations safely.
Related Developer Utilities
Prettify, format, validate, and minify JSON data.
Encode and decode text or files to Base64.
Calculate SHA-256, SHA-384, SHA-512, and SHA-1 checksums.
Encode and decode URI query strings and paths.