Skip to content

Developer tools

Regex Tester with Live Highlighting

Test a regular expression against your text with live highlighting, capture groups and match offsets, plus a replace mode. Runs entirely in your browser.

//g

Global — find every match, not just the first.

Test string

About the regex tester

A regular expression is quick to write and slow to be sure about. The gap between the two is where this page lives: type a pattern, see every match highlighted in your own text, with the capture groups and the character offset for each one. Being able to see what the pattern actually matched is faster than reasoning about what it should.

The flags are the part most people guess at. Global changes whether you get one match or all of them. Multiline changes what ^ and $ mean — anchors of a line rather than of the whole string, which is the fix for nearly every pattern that works on one line and fails on a paragraph. The dotAll flag lets a dot cross line breaks, which it otherwise never does. Each flag here explains itself as you turn it on.

Replace mode uses JavaScript's substitution syntax: $1 and $2 for numbered groups, $<name> for named ones, $& for the whole match. It is the same syntax `String.replace` takes, so what works here works in your code unchanged.

The matching runs in your browser using the same engine your JavaScript uses, which means the results are exactly what you will get at runtime — not a close approximation from a different regex flavour. It also means nothing you paste is uploaded, which matters when the test data is a log file or a customer record.

One safeguard worth knowing about. A global pattern that can match the empty string — /a*/g against text with no As — matches at every position without ever advancing, and a naive implementation loops forever. This one advances past a zero-length match, and caps the list at 500, because past that the pattern is telling you something is wrong with the pattern.

Frequently asked questions

Was this tool helpful?