โšก Regex Performance Tester

๐Ÿ“ Test Text

๐Ÿ” Regex List

Safe
Safe

๐Ÿ“š What Can Regex Performance Tester Do?

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.

Core Features

โ€ข 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

How to Use

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

Use Cases

โ€ข 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

Extended Knowledge

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.

โ“ FAQ

What is a ReDoS attack?

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.

How do I know if my regex has ReDoS risk?

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.

What does backtracking count mean?

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.

Can I compare multiple regexes at once?

Yes. Add multiple regexes and compare their execution speed against the same test text, ranked by execution time.

Can I adjust test iterations?

Yes. Each regex runs 100 times by default (averaged). Adjust iterations (10-10000) for more precise results.

How to optimize regex performance?

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.

Regex Performance Tester | No Signup, Client-Side ยท No Server Uploads

Feedback: dexshuang@google.com