Regex Tester
Test regular expressions with real-time highlighting, capture groups, and ReDoS protection.
Match & Capture Group Breakdown (0)
What Does the Regex Tester Do?
The Regex Tester evaluates JavaScript regular expressions (RegExp) against sample text, highlighting every match directly in the document and listing each match's index, length, numbered capture groups ($1, $2...), and named capture groups (?<name>...).
To protect your browser tab from freezing on pathological patterns susceptible to Regular Expression Denial of Service (ReDoS)—such as nested quantifiers like (a+)+$—evaluation is guarded by a bounded Web Worker timeout and step guard.
Syntax errors in your pattern or flags are caught immediately and explained in plain language.
How to Use This Tool
- Enter your regular expression pattern (without surrounding slashes) and toggle flags such as g (global), i (case-insensitive), m (multiline), or s (dotAll).
- Paste or type your test string in the test editor below, or load one of the built-in pattern presets.
- Inspect the highlighted matches in the preview pane and review the detailed capture group table.
Common Engineering Use Cases
- Designing input validation patterns for emails, slugs, semantic versions, or log line parsers.
- Extracting structured fields from unstructured server logs using named capture groups.
- Auditing existing regular expressions for catastrophic backtracking before deploying them to production Node.js services.
Practical Developer Examples
Extracting Semantic Version Components
Use named capture groups to parse major, minor, patch, and pre-release identifiers.
Pattern: ^v?(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:-(?<prerelease>[0-9A-Za-z.-]+))?$ Text: v2.14.3-beta.1
Match #1: "v2.14.3-beta.1" (index 0) Groups: major="2", minor="14", patch="3", prerelease="beta.1"
Common Mistakes & Pitfalls to Avoid
- Omitting the 'g' (global) flag when expecting to find all matches in a document rather than only the first match.
- Forgetting to escape special metacharacters like dots (\.), brackets (\[), or question marks (\?) when matching literal characters.
- Writing nested repeating groups like (.+)+ that cause exponential backtracking on non-matching strings.
Frequently Asked Questions
How does DevToolbox prevent infinite regex loops from freezing my browser?
When evaluating complex inputs, execution is isolated in a dedicated Web Worker with a strict execution deadline. If an expression takes too long due to catastrophic backtracking, the worker is terminated cleanly and a warning is displayed.