Regex Tester
Test regular expressions with live matching, highlighting, and capture groups — CRITICAL confirmed bug: the tool's claimed "timeout protection" against catastrophic backtracking (ReDoS) does not actually work. Reproduced directly: testing the exact (a+)+ -style pattern this tool's own FAQ uses as its example, against just 30 characters of input, froze the computation for 95 seconds with no timeout triggering at all — the non-global (default) mode has no timeout check whatsoever, and even the global mode's check can't interrupt a single already-hanging match attempt.
\(\\d\{4\}\)-\(\\d\{2\}\)-\(\\d\{2\}\)
How to Use This Tool
Enter your regular expression pattern
avoid deeply nested quantifiers like (a+)+ or (a*)* against anything but very short test strings: confirmed via direct testing, this tool's claimed timeout protection does not actually stop the resulting freeze.
Set flags (global, case-insensitive, multiline, etc.)
note that only the global-flag code path has any timeout check at all, and even that check can only run between completed match attempts, not during one that's already hanging.
Pro Tip
Test your pattern against deliberately malformed input, not just valid examples — a regex that correctly matches 'test@example.com' but also incorrectly matches 'test@@example..com' will pass casual testing and then let genuinely invalid data through in production, which is how most regex validation bugs actually ship. One important caveat specific to this tool, confirmed via direct testing: if the pattern you're testing has nested or ambiguous quantifiers, be careful how you follow that advice — deliberately malformed input is also exactly the kind of input that can trigger catastrophic backtracking, and this tool's claimed timeout protection does not reliably stop the resulting freeze. Start with short malformed strings, not long ones, when testing an unfamiliar or complex pattern.
About This Tool
When to Use
- Building and testing an email or phone number validation pattern against a range of realistic input examples
- Debugging why an existing regex fails to match a specific edge-case string during a support ticket investigation.
- Reverse-engineering an undocumented regex found in a legacy codebase by testing it against sample inputs
Key Details
A regex tester runs a regular expression against sample text in real time, highlighting every match inline and breaking out capture groups individually, making it clear precisely what a pattern catche...
Worked example
Pattern ^(\\d{3})-(\\d{3})-(\\d{4})$ tested against '555-123-4567' produces a full match, with capture group 1 = '555', group 2 = '123', and group 3 = '4567' — instantly confirming both that the overall format matches and that each individual group extracts the expected piece of the phone number; this simple, non-nested pattern is fast and completely safe to test at any input length. Contrast that with a pattern using nested quantifiers, like (a+)+b: reproduced directly, running that pattern against a 30-character string of just "a" characters (no trailing "b", so the match ultimately fails) took 95 seconds to resolve, with the tool's claimed timeout protection never actually stepping in — a dramatic difference in risk between two patterns that might look similarly simple at a glance.
Interpreting your result
A match count and highlighted results appearing within a fraction of a second confirm your pattern is safe and behaving as expected for that input. If the tool appears to hang or freeze after you click into the test string field or edit the pattern, that's the confirmed catastrophic-backtracking gap, not a display bug — the underlying computation really is stuck, and the only way out is closing or reloading the tab (there's no way to cancel a hung match from within the tool itself). Avoid this by testing complex or unfamiliar patterns against very short strings first, and only expanding to realistic-length input once you've confirmed the pattern completes quickly.
Regex Tester FAQ
What regex syntax does this tester support?
This tester uses JavaScript's RegExp engine, supporting: character classes, quantifiers (* + ? {}), groups and backreferences, alternation (|), anchors (^ $), word boundaries (\b), lookahead/lookbehind ((?=) (?!)), named groups ((?<name>)), and Unicode property escapes.
What are regex flags and how do they work?
Flags modify how the pattern is applied: g (global — find all matches, not just the first), i (case-insensitive), m (multiline — ^ and $ match line boundaries), s (dotAll — . matches newlines), u (unicode — enables Unicode features), y (sticky — matches only from lastIndex).
What is catastrophic backtracking (ReDoS), and does this tool's timeout protection actually work?
Catastrophic backtracking occurs when a complex regex (especially nested quantifiers like (a+)+) takes exponential time to fail on certain inputs, and it can genuinely freeze your browser tab. Confirmed via direct testing, this tool's timeout protection does not reliably prevent that freeze. Testing (a+)+b against just 30 characters of input with no trailing "b" — a textbook catastrophic-backtracking case — took 95 seconds to complete with no timeout triggering at all. The non-global (default) mode has no timeout check anywhere in its code path, and even the global mode's check only runs between completed match attempts — it can't interrupt a single regex.exec() call that's already stuck in exponential backtracking, since JavaScript can't preempt synchronous code mid-execution. Treat any pattern with nested or ambiguous quantifiers as a real freeze risk here, and test it against very short strings first.
How do capture groups work?
Parentheses ( ) create capture groups that remember matched portions. Groups are numbered by opening parenthesis position. (\d+) captures digits as group 1. Named groups like (?<year>\d{4}) capture by name. Non-capturing groups (?: ) group without capturing.
Why does my regex work in some tools but not here?
Different programming languages use different regex engines with different features and defaults. This tester uses JavaScript's engine. For example, JavaScript doesn't support possessive quantifiers or recursion that PCRE/PHP supports. Check your regex against the JavaScript spec.
What's the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, {n,m}) match as much text as possible while still allowing the overall pattern to succeed. Lazy quantifiers (*?, +?, {n,m}?) match as little text as possible. Example: in '<div>hello</div>', /<div>.*</div>/ (greedy) matches the whole string, while /<div>.*?</div>/ (lazy) matches just '<div>hello</div>'. Catastrophic backtracking can occur with deeply nested greedy quantifiers like (a+)+ — confirmed via direct testing, this tool's own timeout safeguard doesn't reliably catch that case, so test nested-quantifier patterns against short strings first; see the dedicated question above for the specifics.
Master Your Entire Toolkit
Access 500+ specialized calculators and tools designed for precision. No sign-up required, 100% free.
Built and reviewed by the Toolzip Team · Based on MDN Web Docs — Regular Expressions and ECMAScript RegExp Specification