The Regex Performance Tester compares execution speed of multiple regexes against the same text, detects ReDoS (Regular Expression Denial of Service) risk, and helps developers write efficient, safe regular expressions. Supports multi-regex comparison, risk detection, and performance ranking.
โข Multi-regex comparison: test multiple regexes simultaneously
โข ReDoS risk detection: auto-analyze nested quantifiers and alternation overlap
โข Performance ranking: sort by execution time to show the fastest regex
โข Adjustable iterations: 10-10000 runs for averaged results
โข Timeout protection: prevent browser freeze from malicious regexes
1. Enter test text (or load example)
2. Add regex patterns and flags to compare
3. Set iterations and timeout
4. Click "Run Test" to see performance ranking and risk levels
โข Regex Optimization: Compare performance of different regex approaches
โข Security Audit: Detect ReDoS risk in user-input regexes
โข Teaching Demo: Show how backtracking affects performance
โข Code Review: Verify project regexes are safe and efficient
Regex engines are either NFA (Non-deterministic Finite Automaton) or DFA (Deterministic Finite Automaton). JavaScript uses NFA, which supports backreferences but can cause exponential backtracking. ReDoS attacks exploit nested quantifiers (like (a+)+b) to create exponential backtracking. Defenses include: limiting input length, setting match timeouts, using atomic groups, and avoiding nested quantifiers.
ReDoS exploits regex backtracking by crafting malicious input that causes exponential backtracking, leading to high CPU usage or service crashes. Example: /(a+)+b/ matching 'aaaaaaaaac' triggers massive backtracking.
This tool analyzes regex patterns for nested quantifiers and alternation overlap to detect ReDoS risk, color-coded: red = high risk, yellow = medium risk, green = safe.
Backtracking count is the number of times the regex engine backtracks to try alternative paths when a match fails. Higher backtracking means lower efficiency and greater ReDoS risk.
Yes. Add multiple regexes and compare their execution speed against the same test text, ranked by execution time.
Yes. Each regex runs 100 times by default (averaged). Adjust iterations (10-10000) for more precise results.
Common optimizations: avoid nested quantifiers, use non-capturing groups (?:), use atomic groups, be specific in patterns, avoid overlapping alternation, and pre-compile frequently used regexes.