At One Place

Regex tester

Test a regular expression against sample text, with matches and capture groups shown.

How it works

Tests a JavaScript regular expression against sample text, listing every match with its position and capture groups.

Flags matter more than people expect. Without the global flag only the first match is returned; without multiline, the anchors ^ and $ match the start and end of the whole string rather than of each line. Most confusion about a regex that "does not work" comes down to one of those two.

A caution worth stating: a badly-formed regex can take exponential time on certain inputs, a failure known as catastrophic backtracking. Nested quantifiers like (a+)+ are the classic trigger. It matters because a regex run on user input is then a denial-of-service vector, and this is a genuine class of production incident rather than a theoretical concern.

This uses your browser’s own engine, so the behaviour matches JavaScript exactly. Other languages differ — lookbehind, named groups and Unicode handling all vary between PCRE, Python and Go.

This tool runs entirely in your browser. Nothing you enter is sent to a server, logged or stored, and the page keeps working with the network disconnected.

Common questions

Why does my regex only match once?
The global flag is missing. Without it, matching stops at the first result.
What is catastrophic backtracking?
A pattern whose matching time grows exponentially on some inputs, usually from nested quantifiers like (a+)+. Run on user input it becomes a denial-of-service vector.
Will this regex work in Python?
Not necessarily. This uses the JavaScript engine; lookbehind, named groups and Unicode handling all differ between engines.

Related pages

Sources

  1. Calculated on this page — At One Place

How these figures are compiled and checked