Free tool · No signup · Instant results

    Online Regex Tester: Test, Debug, and Explain Regular Expressions

    Free online regex tester for JavaScript. Real-time match highlighting, capture group visualization, and performance profiling. No install required.

    Test Your Regex Pattern →

    Regular expressions are powerful but notoriously difficult to debug. A regex that "should work" often doesn't, and figuring out why requires seeing exactly what the engine is matching. An online regex tester gives you immediate visual feedback on what your pattern matches, where it fails, and what your capture groups contain.

    JavaScript Regex Flags: The Essential Reference

    g (global): Find all matches, not just the first. Without this flag, /pattern/.test() stops after the first match.

    i (case insensitive): /hello/i matches "Hello", "HELLO", "hElLo".

    m (multiline): Makes ^ match the start of each line (not just the string) and $ match the end of each line.

    s (dotAll): Makes . match newline characters too. Without this, . matches everything except \n.

    d (indices): Populates the indices property of the match result with start and end positions for each match and capture group.

    Capture Groups vs Non-Capturing Groups

    Capture groups (x) capture the matched text and make it available via match[1], match[2], etc. They're the primary way to extract parts of a match.

    Named capture groups (?<name>x) give your captures readable names: match.groups.name instead of match[1]. Dramatically improves readability for complex patterns.

    Non-capturing groups (?:x) group without capturing. Use these when you need the grouping for alternation or quantification but don't need the captured value — it avoids polluting your capture group index array.

    Lookaheads (?=x) and lookbehinds (?<=x) match positions without consuming characters. They're powerful for assertions that don't appear in the final match.

    Performance: The Catastrophic Backtracking Problem

    Certain regex patterns cause exponential backtracking — the engine tries so many combinations that it takes seconds or even minutes to return a result on certain inputs. This is called "Catastrophic Backtracking" and it's a real denial-of-service vector in production systems.

    The patterns to watch: nested quantifiers like (a+)+ on strings with many 'a' characters. The classic example: /^(a+)+$/ against "aaaaaaaaaaaaaaaaX" triggers exponential backtracking in most engines. Use possessive quantifiers (a++)+ or atomic groups in engines that support them. For JavaScript, rewrite to eliminate nested variable-length quantifiers.

    Debugging a regex by staring at it rarely works. You need to see what it's actually matching. Use the tester to paste your pattern and test string, watch matches highlight in real time, inspect capture groups, and profile performance on your specific input.

    RegEx Tester — free, instant, no signup

    100% client-side. Your data never leaves your browser.

    Test Your Regex Pattern →

    Frequently Asked Questions

    Does the regex tester use JavaScript regex?+

    Yes. The engine is JavaScript's native RegExp, so the behavior matches exactly what you'll get in Node.js and modern browsers.

    What is a capture group in regex?+

    Parentheses (x) create a capture group that stores the matched text. You access it via match[1], match[2], etc. Named groups (?<name>x) use match.groups.name.

    What is catastrophic backtracking?+

    When certain patterns on certain inputs cause the regex engine to try exponentially many paths before failing. Can cause near-infinite computation. Avoid nested quantifiers like (a+)+.

    Related guides