Regex Tester & Debugger
Real-time regular expression parser, syntax validator, capture group extractor, string substitution engine, and performance benchmarker.
Regular Expression & Text Input
Active Parser
/
/
Pattern is compiled client-side in pure vanilla JavaScript.
221 chars
matches
Iteration ceiling ensuring fast response and zero UI freezes.
chars
Total Matches
4
Captured Groups
8
Matched Characters
90 chars
Execution Benchmark
0.14 ms
Match Distribution Map & Coverage Tape
40.7% Covered
Live Match Highlighting Preview
Interactive View
Contact our team at support@example.com or sales@enterprise.org.
For billing inquiries, reach out to billing.dept@company.co.uk today!
Invalid email: user@.com, test@domain
Another valid address: dev-team_42@sub.domain.io
| # | Matched Substring | Indices | Length | Capture Groups |
|---|---|---|---|---|
| 1 | support@example.com | [20–39] | 19 | 1: support, 2: example.com |
| 2 | sales@enterprise.org | [43–63] | 20 | 1: sales, 2: enterprise.org |
| 3 | billing.dept@company.co.uk | [101–127] | 26 | 1: billing.dept, 2: company.co.uk |
| 4 | dev-team_42@sub.domain.io | [196–221] | 25 | 1: dev-team_42, 2: sub.domain.io |
Compiled JavaScript RegExp Engine:
/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/gi
Engine Status: Valid regular expression. 4 matches parsed in 0.14 ms.
* Pattern evaluation is performed entirely in your local browser sandbox via native JavaScript RegExp execution with zero server transmission.
Detailed Regex Pattern Breakdown
| Token | Category | Meaning & Clinical Action |
|---|---|---|
([a-zA-Z0-9._%+-]+) | Capture Group 1 | Captures username; matches letters, digits, dots, underscores, percents, pluses, or hyphens 1+ times. |
@ | Literal Character | Matches the mandatory "@" delimiter. |
([a-zA-Z0-9.-]+) | Capture Group 2 (Subdomain) | Matches domain labels containing alphanumeric characters, dots, or hyphens. |
\. | Escaped Meta-character | Matches a literal period character "." separating domain labels from the TLD. |
[a-zA-Z]{2,} | Character Class & Quantifier | Matches top-level domain extension of 2 or more alphabetic characters. |
Common Regular Expression Recipes
- Standard Email:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ - URL Validator:
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*) - US Phone Number:
^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$ - ISO 8601 Date:
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ - Hex Color Code:
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$
Preventing Catastrophic Backtracking (ReDoS)
Regular expression engines use backtracking algorithms when resolving ambiguous quantifiers. Expressions featuring nested repetitions (such as (a+)+$ or ([a-zA-Z]+)*) can exhibit exponential runtime complexity O(2^n) on strings ending in mismatched characters. To prevent browser lockups and Denial-of-Service vulnerabilities:
- Avoid nested quantifiers where inner and outer clauses match the same characters.
- Keep search spaces concrete by substituting generic
.*wildcards with explicit negated character sets (e.g.[^"\n]*). - Use the Max Match Cap slider in this debugger to enforce strict loop execution bounds during development.
How to Use This Tester & Debugger
- Enter Your Regular Expression: Type your pattern into the input bar and toggle necessary flags (g, i, m, s, u).
- Input Test Text: Paste or type your target text into the multiline editor.
- Inspect Matches & Capture Groups: Examine the distribution minimap, highlighted match preview, and structured group extraction table.
- Test Substitutions: Switch to the Replace tab to experiment with dynamic string substitutions using group variables.
Important Regex Terms
- Anchor: Zero-width assertions asserting position:
^(start of line) and$(end of line). - Quantifier: Specifies repetition:
*(0+),+(1+),?(0 or 1),{n,m}(between n and m times). - Character Class: A bracketed set matching any single character from the collection (e.g.
[0-9]or\d). - Lookahead / Lookbehind: Asserts whether subsequent or preceding characters match without consuming them (
(?=...),(?<=...)).
Frequently Asked Questions
The 'g' (global) flag tells the regex engine to search for all matching occurrences throughout the entire string rather than stopping after the first match.
A match is the complete substring that satisfies the full regular expression pattern. A capture group isolates specific sub-components enclosed in parentheses ( ) for targeted extraction.
Catastrophic backtracking occurs when nested ambiguous quantifiers (such as (a+)+) force the engine through exponential alternative pathways on unmatched strings. Prevent it by eliminating overlapping quantifiers and using atomic groupings.
Lookaheads (?=...) and lookbehinds (?<=...) are zero-width assertions that verify conditions immediately after or before the current position without consuming characters into the match.
JavaScript supports 'g' (global), 'i' (case-insensitive), 'm' (multiline), 's' (dotAll), 'u' (unicode), and 'y' (sticky).