Turn a regular expression into a railroad diagram — branches and loops
drawn like track — next to a plain-English reading and its
capture groups. Traps that apply to your pattern are called out:
catastrophic backtracking in shapes like (a+)+, the fact that
. never matches a newline, and more.
The page also builds example strings from the diagram and tests them against your pattern,
so if the drawing and the expression disagree, you find out here.
Each example is assembled from the parsed structure alone — the same structure the diagram is drawn from — and then tested against your original expression. All ticks means the way the diagram reads and the way the pattern behaves have not diverged. To try your own strings, use the Regex Tester.
▶ on the left
to the ◀ on the right, and the boxes you pass through, concatenated,
form a string this expression matches. At a branch you take exactly one path;
at a loop you repeat as many times as you go around.| is tried left to right. Where a loop is labelled lazy, as with
*?, the engine tries going around as few times as possible first.\1 or $1. An orange dashed box is a lookahead or lookbehind:
it checks a condition without consuming any characters, so passing through it
does not move the position forward.canvas, so nothing overflows when the font differs.RegExp, and checks that they accept and reject exactly the same ones.v-flag character classes and the finer
\p{...} categories are shown as a single box rather than expanded.
If a pattern is too tangled to draw, the page says so instead of drawing something wrong.