Back to the blog

Developer

A regex tester that explains, draws and warns.

Test a regex in your browser, nothing uploaded: JavaScript, PCRE2 or Go, matches marked as you type, each part explained and drawn, and backtracking found.

By Updated 5 min read

A developer toolkit reading encoded text in two steps, URL decode then Base64 decode, to give Hello, world!

A regular expression is quick to write and slow to read. A good tester shows what it matches, why, and what it will do on the text that breaks it, before that text reaches a server.

Type a pattern, see what it matches.

Open the regex tester, choose the flavour and type a pattern and a text: matches are marked as you type, each with its place and its groups, named groups included. Replace shows the text with $1 and $<name> filled in, Split cuts it at each match, and List writes each match on a line.

Each flavour runs in its own engine, never an imitation: JavaScript in your browser's, PCRE2 (PHP, R, nginx) as PCRE2 itself compiled to WebAssembly, and Go's regexp ported to JavaScript. Python, Java and .NET are not run; the code panel writes the pattern for them, in eight languages, and notes what they read differently.

Read it, and see it.

What it means explains each part of the pattern in plain words, with its groups numbered as the engine numbers them, and draws it as a railroad diagram: the line runs through what must match, branches for alternatives and loops back for repeats.

Catastrophic backtracking, before it happens.

A pattern such as (a+)+$ can try so many ways to match that a text of a few dozen characters takes minutes: a regular expression denial of service. The tester analyses the pattern before running it, says which part is at fault, offers a text that shows it, and a pattern that matches the same without the fault where one can be found. A run that takes more than two seconds is stopped.

Tests, and patterns to start from.

Add texts the pattern must and must not match; they run with every change. Common patterns (an email address as browsers check one, IPv4 and IPv6, UUIDs, dates, semantic versions, phone numbers in E.164) come with their own tests, which pass in every engine they are said to work in.

Nothing leaves your browser.

Everything is worked out on your device: what you paste or open is never sent anywhere, and nothing is kept when you leave. A share link carries what you typed after the #, which browsers never send to a server.

Further reading

Topics: regex tester · regex101 alternative · regular expression tester · regex explain · regex cheat sheet · pcre tester · redos · railroad diagram

A little less theory. A little more doing.

Try it on your own terms, with a free browser tool.

Try the tool