Online RegEx Tester & Visual Debugger
Test and analyze regular expressions in real-time. Inspect match positions, extract capture groups, preview string substitutions, and copy production-ready code snippets.
Live Match Highlighter
Capture Groups & Match Inspector
| # | Full Match | Position (Span) | Length | Capture Groups |
|---|---|---|---|---|
| 1 | contact@hifitoolkit.com | 0 .. 23 | 23 chars | None |
| 2 | john.doe+tech@sub.example.co.uk | 24 .. 55 | 31 chars | None |
| 3 | invalid..email@domain.com | 56 .. 81 | 25 chars | None |
| 4 | hello_world@tech-company.org | 82 .. 110 | 28 chars | None |
Comprehensive Guide to Regular Expressions: Architecture, Metacharacters & Performance
Regular expressions (RegEx) are foundational to modern computing, powering search engines, compilers, input validators, systems administration scripts, and data pipelines. Whether you are validating email formats in Next.js, analyzing Apache access logs on a production server, or performing syntax transformations in Python, regular expressions provide a mathematically rigorous declarative pattern-matching language.
The HiFi Toolkit RegEx Tester & Visualizer executes natively inside your browser using the JavaScript V8 ECMAScript RegExp engine. Because all compilation, execution, and group extraction happen client-side, your confidential API tokens, source code, and customer records remain strictly private with zero network exposure.
Essential Character Classes & Metacharacters
| Token | Description | Equivalent Syntax | Matching Example |
|---|---|---|---|
| \d | Any numeric ASCII digit | [0-9] | Matches "5" in "Item 5" |
| \D | Any non-digit character | [^0-9] | Matches "I" in "Item 5" |
| \w | Word character (alphanumeric + underscore) | [a-zA-Z0-9_] | Matches "user_1" |
| \W | Non-word character (punctuation/whitespace) | [^a-zA-Z0-9_] | Matches "@", "!", " " |
| \s | Whitespace character (space, tab, newline) | [\r\n\t\f\v ] | Matches tabs and line breaks |
| \b | Word boundary assertion (zero-width) | Boundary between \w and \W | \bcat\b matches "cat" but not "catch" |
| . | Wildcard matching any single character | [^\r\n] (or all with /s flag) | a.c matches "abc", "a-c" |
Understanding Quantifiers: Greedy vs. Lazy
Quantifiers define how many times an engine should match the preceding token. By default, regular expression quantifiers are greedy: they consume as much text as possible, only relinquishing characters through backwards backtracking when the remainder of the pattern fails to match. Adding a question mark makes the quantifier lazy (reluctant).
Greedy Quantifiers (*, +, ?, {n,m})
Pattern <.*> evaluated on <b>bold text</b> will match the entire string from the opening <b> to the closing </b> in one single sweep.
Lazy Quantifiers (*?, +?, ??, {n,m}?)
Pattern <.*?> evaluated on <b>bold text</b> matches minimally, yielding two distinct matches: <b> and </b>.
Lookaround Assertions: Lookahead and Lookbehind
Lookaround assertions are zero-width checks that inspect characters ahead of or behind the current position without including them in the final match string:
- Positive Lookahead
(?=...): Asserts that the subpattern matches immediately after the current position. Example:\d+(?=px)matches250in "250px" without matching "px". - Negative Lookahead
(?!...): Asserts that the subpattern does NOT follow. Example:\b(?!admin\b)\w+matches all words except "admin". - Positive Lookbehind
(?<=...): Asserts that the subpattern precedes the current position. Example:(?<=\$)\d+on "$499" matches "499". - Negative Lookbehind
(?<!...): Asserts that the subpattern does NOT precede. Example:(?<!\\)"matches unescaped double quotes.
Preventing Catastrophic Backtracking and ReDoS Attacks
A Regular Expression Denial of Service (ReDoS) vulnerability occurs when a regex engine encounters catastrophic backtracking. If an expression contains nested ambiguous quantifiers like (a+)+$, evaluating a non-matching string of 30 "a" characters followed by an "x" forces the engine to test over 1,073,741,824 permutations, causing 100% CPU lockup. To prevent ReDoS, avoid nesting unbounded quantifiers and enforce strict input length limits before pattern evaluation.
Frequently Asked Questions (RegEx FAQs)
Explore Related Tools
Hand-picked utilities and calculators related to this tool.