What this regex visualizer does
Regular expressions are write-only for most people: easy to type, hard to read a week later. This tool parses your pattern into a syntax tree and shows it three ways. A railroad diagram draws the pattern as a track you can follow from left to right, with branches for alternation, loops for repetition and labeled boxes for groups. A plain-language explanation walks through every token ("one or more digits", "named group year", "not followed by"). And code snippets show how to use the exact pattern with the correct escaping in JavaScript, Python, Go, Java, C#, PHP and Rust. A live test string highlights matches as you type.
How to use it
- Type or paste a pattern. You can include slashes and flags like
/^\d{4}-\d{2}$/gmor enter the flags separately. - Follow the railroad diagram to see the overall shape of the pattern.
- Read the explanation list for a token-by-token description.
- Enter a test string to see what matches and which groups capture what.
- Copy a ready-made snippet in your language.
Reading the railroad diagram
- Rounded boxes are literal text; square boxes are character classes like digit or one of a–z.
- A path that splits into parallel rails is an alternation (
a|b). - A rail that loops back under a box means "repeat"; a rail that bypasses the box means "optional".
- Dashed frames are groups; capture groups are numbered and named groups show their name.
- Lookarounds are drawn as labeled frames because they check text without consuming it.
Tips
- Prefer
\dand character classes over long alternations for speed and clarity. - Lazy quantifiers (
*?,+?) are shown with "as few as possible" in the explanation. - When porting patterns, remember that Go's RE2 engine does not support lookarounds or backreferences; the Go snippet warns you when your pattern uses them.
- Escape backslashes in normal string literals, or use raw strings (
r"..."in Python, backticks in Go) as the snippets do.