Regex Playground

// what it does and why

A regular expression is a compact way to describe a shape of text, and the quickest way to be confidently wrong about one. This is a scratchpad for building one: type a pattern, paste text you actually care about, and watch what it catches while you type.

Open it →
26Symbols explained
4Highlight colours
5,000Match ceiling
0Network requests

What it does

Two boxes to fill in and three answers back. The top box takes the pattern, with a short field beside it for the flags. The box under it takes your test text. Below those: the same text again with every match shaded, a running count, and a breakdown of what the pattern says in plain english.

Everything updates on every keystroke. There is no run button, so a half-finished pattern is already telling you something. If the pattern will not compile, the error line shows the browser's own message rather than a friendlier invented one, because the browser is the thing that has to accept it and its complaint is the one that matters.

Matches are shaded in four colours that cycle, so two hits sitting next to each other never blur into one block. Capture groups are not shaded separately yet, which is the next thing I want to add.

Why it exists

Writing a pattern against real data is normally a loop: edit it, save, run it, squint at the output, edit again. The loop is slow enough that you settle early. You end up with something that works on the three lines you happened to test, and you ship it.

The failure is always the same shape. A pattern that is broken tells you immediately. A pattern that is slightly too greedy does not. It catches everything you checked, plus something you never looked at. Seeing the whole text lit up is the only reliable way to notice, because the highlighting answers the question you did not think to ask.

It is for anyone who writes a few patterns a month and relearns them every time: filtering a log, validating one form field, a find and replace that has to not go wrong. What it saves is the round trip.

The plain english part

The breakdown reads your pattern left to right and names each piece as it goes: this is a quantifier, this is a character class, this is a word boundary, this is an alternation. It knows 26 pieces of syntax. Anything it does not recognise falls through and is reported as literal text, so it always returns an answer instead of refusing.

That fallback is also its honest limit. Lookahead, lookbehind, backreferences and named groups are not among the 26, so the breakdown will quietly describe them as ordinary groups and ordinary characters. The highlighting stays correct, because the browser does the actual matching and the browser knows all of it. It is only the explanation that goes vague once the syntax gets advanced.

Two things that would otherwise hang the page

The search always turns the global flag on, whatever you typed in the flags box. Without it the engine stops at the first hit, and a highlighter that shows one match is not a highlighter. Worth knowing when you are reading the count: it is the count with global on, even if you left it off.

The other one is subtler. Some patterns match successfully while consuming no characters at all. The search then finds the same empty match at the same position forever and the tab locks up, so empty matches are stepped past. There is also a ceiling of 5,000 matches, and the breakdown stops after 400 steps, so pasting in something enormous cannot take the page down with it.

Nothing leaves the browser

The text you paste is usually the reason you needed the tool: a log excerpt, a column out of an export, a list of addresses. None of it is sent anywhere. The page makes no network requests, saves nothing, and has no server behind it.

What I took from it: the version I trust is not the one that tells me my pattern is valid. Valid was never the problem. It is the one that shows me the text I did not think to check.