Regex Tester

Test a regular expression against sample text and see every match and capture group highlighted live.

//g
How this tester works

Your pattern and flags are passed straight to JavaScript’s own RegExp constructor inside a try/catch, so an invalid pattern — an unclosed character class, a bad flag — shows a clear error instead of crashing. With the g flag, every match is found with matchAll; without it, only the first match is found with exec, matching how the flag actually behaves rather than forcing it on. The highlighted view slices your test text around each match’s index and renders the pieces as plain React text, so special characters in your text are displayed safely rather than interpreted as markup.

Frequently asked questions

What do the g, i, m, and s flags mean?

g (global) finds every match in the text instead of stopping at the first one. i makes matching case-insensitive. m (multiline) makes ^ and $ match the start and end of each line rather than only the start and end of the whole string. s (dot-all) makes . also match newline characters, which it otherwise doesn't.

Why does my regex work in another tool but not here?

This tool uses JavaScript's own RegExp engine, and JS regex has some real differences from PCRE, Python's re, or other engines — variable-length lookbehind support varies by browser and JS engine version, there's no \K reset-match operator, and possessive quantifiers and atomic groups aren't supported at all. A pattern written for a different engine may need small adjustments to run here.

Can I test named capture groups?

Yes — write them as (?<name>...) in your pattern, and each match's named groups appear in the "Named" line under that match, alongside the numbered positional groups.

Why doesn't the highlighted view show anything without the g flag?

It does, but only the single first match is highlighted — without g, JavaScript's regex engine (and this tool, faithfully) only reports the first match rather than scanning the whole text. Turn on g to see every match highlighted and listed.

Is my regex or test text sent anywhere?

No. Building the RegExp object and running it against your test text both happen entirely in your browser as you type — nothing is uploaded or logged.

Related tools

Command Palette

Search for a command to run...