Plan position indicator · long-persistence phosphor

Regex Tester

Type a pattern and a text. Every match is a contact on the scope: it paints bright as the sweep passes and fades until the next turn. Groups, flags and a replace preview sit on the console.

Bearing = position in the text · ring = which match

//g

Matches painted

Contacts

Signal codes · quick reference

Test a regular expression

A regular expression is a pattern that describes text: \d{4}-\d{2}-\d{2} is any date written year-month-day, ^\s*$ is a blank line, (\w+)@(\w+)\.\w+ is a rough email address with the user and domain captured as groups. This page runs your pattern in the browser's own JavaScript engine, so what matches here matches in JavaScript, Node and most editors with the same syntax.

Reading the console

Matches are highlighted in the text and listed as contacts with their position and every capture group, numbered and named. Flags change the rules: g finds every match instead of the first, i ignores case, m lets ^ and $ match at line breaks, s lets a dot match a newline, u turns on full Unicode. The replace field shows what text.replace(pattern, replacement) would give, with $1, $2 or $<name> standing for the groups.

Why a radar

A search is a sweep. A plan position indicator draws a line turning about the centre in step with the antenna, and each echo paints bright where the beam finds it, then fades on the long-persistence phosphor until the next pass. Here the text is the range: a match near the start of the text paints near the top of the scope, one near the end paints just before the sweep returns.

Why does it say NO SIGNAL?

The pattern is not valid: an unclosed bracket, a stray backslash at the end, a quantifier with nothing before it. The line under the pattern quotes the engine's reason.

Why does it find only one match?

The g flag is off. Without it a regex stops at the first match, which is how JavaScript behaves too.

Can it hang?

Some patterns backtrack catastrophically on the wrong text, for example (a+)+$ against a long run of a's. Keep the test text modest while you build a pattern, the way you would in an editor.

Is anything uploaded?

No. The pattern and the text stay in your browser.

Radar · PPI scope · 4-second sweepAll tools
Suggest an improvement