Regex Tester & Match Debugger

Test regular expressions against your own text with live match highlighting, capture group inspection, and a replace preview — all in your browser.

/ /
Test string 0 matches

Matches

    Replace preview
    
        

    About this tool

    How to use it

    1. Type or paste a regular expression into the pattern field — no leading/trailing slashes needed, just the pattern itself.
    2. Set flags in the box next to it: g to find every match (not just the first), i for case-insensitive, m for multiline ^/$, s for dotAll.
    3. Paste your test string below. Matches highlight inline as you type, with a running count above the editor.
    4. Click Test Pattern, or just keep typing — matches and the match list both update live once the pattern is valid.
    5. Optionally add a replacement string (using $1, $2 for capture groups, or $& for the whole match) to preview what String.replace() would produce.

    Why it matters

    A regular expression that looks right rarely behaves exactly as expected on the first try — an unescaped character, a greedy quantifier that eats too much, or a missing global flag that silently stops after the first hit. Testing against your actual data, with every match highlighted and every capture group broken out individually, catches these before the regex ships inside real code.

    When to use it

    Debugging a regex that's matching too much, too little, or nothing at all in your own code. Working out the right pattern for form validation, log parsing, or a find-and-replace across a codebase before committing to it. Checking what a capture group actually captures, rather than guessing from the pattern alone.

    Good to know

    Uses the browser's native RegExp engine directly — the exact same engine and flag behaviour (g, i, m, s, u, y) your JavaScript code will run with, not a separate regex flavour like PCRE or Python's re module. Patterns from other languages that use different escape syntax (e.g. \d vs [0-9], named groups syntax) may need adjusting for JavaScript.

    Common questions

    Why do I only see one match even though my pattern should match several times?

    Add the g (global) flag. Without it, JavaScript's regex engine stops after the first match by design — this tool mirrors that exactly, including the note under the match count telling you why.

    What regex flavor does this use?

    JavaScript's native RegExp engine, running in your own browser — the same one Node.js and every browser's JavaScript uses. If you're porting a pattern from Python, PCRE, or another language, some syntax (character classes, named groups, lookbehind support) can differ slightly.

    How do I reference a capture group in the replacement?

    Use $1, $2, and so on for numbered groups in the order they appear in the pattern, $<name> for a named group ((?<name>...)), and $& to insert the whole match. These follow the same syntax as JavaScript's String.replace().

    Is my pattern or test string sent anywhere?

    No. The regex engine runs entirely in your browser tab — nothing you type is uploaded, logged, or stored.

    Why does my pattern show an error instead of matching?

    The message under the pattern field is JavaScript's own SyntaxError from compiling the regex — usually an unbalanced bracket or parenthesis, or a flag combination that isn't valid together (like u and unicode property escapes that don't apply here).