Regex Tester

Client-sideNo sign-upFree

Test a regular expression against a string with live highlighting and capture group output.

How this tool works

1

Enter a pattern

Your regular expression, without the surrounding slashes.

2

Toggle the flags you need

g, i, m, and s can each be switched on or off independently.

3

Paste a test string

The text you want to check the pattern against.

4

Read the highlighted matches

Matches are marked inline, with a full list of matches and capture groups below.

Quick facts

Category
Text Tools
Best for
Confirming a regex matches before it ships in code
Pattern
✓ 2 match(es)
Test string
Highlighted result
Contact us at hello@formatiq.com or support@formatiq.com for help.
Matches
1. "hello@formatiq.com" at index 14 - groups: ["hello", "formatiq.com"] 2. "support@formatiq.com" at index 36 - groups: ["support", "formatiq.com"]
In-content slot

About this tool

Enter a regex pattern and a test string to see every match highlighted directly inline in the text, with a separate list below showing each match’s exact position and any capture groups it contains. Toggle the g, i, m, and s flags independently to see how each one changes matching behavior - g finds all matches instead of stopping at the first, i ignores case, m makes ^ and $ match at line boundaries instead of only the start/end of the whole string, and s lets "." match newline characters. If the pattern itself has invalid syntax - an unclosed group, a bad character class - the JavaScript regex engine’s own error message is shown immediately rather than a generic failure, so you can see exactly what needs fixing. Runs entirely client-side using the browser’s native RegExp engine, the same one your actual JavaScript code will use.

Why use this tool

Inline match highlighting

See exactly where matches occur directly in the text, not just a count.

Capture groups shown

Every match’s groups are listed individually, useful for debugging extraction logic.

Native JavaScript engine

Uses the browser’s own RegExp implementation, the same one your code will actually run on.

Real syntax error messages

An invalid pattern shows the actual engine error, not a generic "invalid regex."

Frequently asked questions

Without the g (global) flag, JavaScript’s regex engine stops after finding the first match. With it, the engine keeps searching from where the previous match ended, finding every non-overlapping occurrence in the string. This tool always searches globally regardless of whether you’ve toggled g on, since seeing all matches is almost always what you want when testing a pattern - the g toggle mainly matters if you copy the pattern into your own code afterward.

JavaScript’s regex syntax has some differences from other languages and tools (PCRE, Python’s re module, POSIX), so a pattern that works in one of those may use syntax JavaScript doesn’t support, like certain lookbehind variations in older engines or named groups written differently. The error message shown comes directly from the browser’s RegExp constructor, so it reflects exactly what a real JavaScript environment would reject.

Explore more free tools

Formatters, converters, validators, and generators - all free and running entirely in your browser.

Browse more tools