Skip to tool

Free online tool

Regex Tester

e.g. \d{4}-\d{2}-\d{2}

e.g. g, i, gi

Your input never leaves your browser.

What this tool does

Type a regular expression and some text, and the tool shows you exactly what it matches — highlighted directly in your text, with the match count and any named capture groups shown alongside. It uses your browser's own, standard JavaScript regular-expression engine, so what you see here is exactly how the same pattern will behave in real JavaScript code.

A real, worked example

Testing the pattern \d{3}-\d{4} with the global flag against "Call 555-1234 or 555-5678" finds 2 matches. Named capture groups work too: testing (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) against "2024-03-15" captures year, month, and day as separate, labeled pieces you can reference by name in your own code.

The global flag changes what you see

Without the g flag, a pattern reports only its first match in the text, exactly matching how JavaScript's own RegExp.exec() behaves by default. Add g to find every match instead of just the first one. This distinction trips people up often enough that it's worth testing both ways if your results look incomplete.

Flags you can combine

Common flags include g (global — find every match, not just the first), i (case-insensitive), m (multiline, so ^ and $ match the start/end of each line rather than only the whole string), and s (dot matches newlines too). Enter any combination, like gi, in the flags field.

Safety: your text is never executed as code

A match containing something that looks like HTML or a script tag is always shown as plain, literal text — never rendered or executed. This matters if you're testing a pattern against user-submitted content that might contain malicious markup; this tool won't accidentally run it.

Invalid patterns

If your pattern has invalid syntax — an unclosed group, say — the tool tells you so directly, using the same error message your browser's own JavaScript engine would produce, rather than silently showing no matches.

A note on complex patterns

Certain pattern shapes (nested repetition, like (a+)+) can make matching extremely slow against certain input — a well-known issue called catastrophic backtracking. This tool flags patterns that look like this shape before running them, as a heads-up, though this check is a heuristic, not a guarantee against every slow pattern.

Privacy

Your pattern and test text are matched entirely in your browser. Nothing is transmitted, logged, or stored anywhere.

Examples

  • Input: Pattern \d{3}-\d{4} (global) against "Call 555-1234 or 555-5678"

    Output: 2 matches found