Regex explainer

Paste a regular expression, with or without the slashes, and get a tree of its parts with a plain-words explanation of each: what a character class accepts, how many times a quantifier repeats, what a group captures and what a lookahead checks. Errors are shown with their position.

A pattern like \d{3}-\d{4}, or a literal like /\d+/g
/^(?<user>[\w.+-]+)@([a-z\d-]+\.)+[a-z]{2,}$/i
  • ii: ignore case, A matches a.
  • ^The start of the text.
  • (?<user>[\w.+-]+)Capturing group #1 named “user”:
  • +One or more times, as many as possible:
  • [\w.+-]One character from this set:
  • \wA word character: a Latin letter A–Z or a–z, a digit 0–9 or an underscore.
  • .+-One of the characters . + -.
  • @Matches the character “@”.
  • +One or more times, as many as possible:
  • ([a-z\d-]+\.)Capturing group #2:
  • +One or more times, as many as possible:
  • [a-z\d-]One character from this set:
  • a-zA character from “a” to “z”.
  • \dA digit from 0 to 9.
  • -Matches the character “-”.
  • \.Matches “.” literally (a special character escaped with \).
  • {2,}2 or more times, as many as possible:
  • [a-z]One character from this set:
  • a-zA character from “a” to “z”.
  • $The end of the text.

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Type or paste a pattern, such as ^\d{3}-\d{4}$, or a whole literal like /colou?r/gi.
  2. Enter flags in the Flags box if you did not paste a literal.
  3. Read the tree: each row shows a part of the pattern on the left and what it does on the right. Indented rows belong to the group, class or quantifier above them.

How it works

The tool parses the pattern with the JavaScript grammar: alternatives split by |, then terms with their quantifiers, then groups, classes and escapes inside them. A run of plain characters is shown as one piece of text, unless a quantifier follows: in abc+ only the c repeats, so the tree shows the text “ab”, then “one or more times” for c.

Without the u or v flag, browsers accept a few legacy forms (a lone { or ], an unknown escape like \q meaning q), and so does the explainer. After parsing, the pattern is also compiled with new RegExp, so a pattern that JavaScript would reject is never explained as if it worked.

Worked example

^(?<year>\d{4})-(0[1-9]|1[0-2])$ reads as:

  • ^ the start of the text;
  • (?<year>…) capturing group #1 named “year”: exactly 4 times, as many as possible, a digit from 0 to 9;
  • - the character “-”;
  • (…) capturing group #2: one of 2 alternatives — the character “0” then a character from “1” to “9”, or the character “1” then a character from “0” to “2”;
  • $ the end of the text.

So it accepts 2026-07 and 2026-12, but not 2026-13.

Tips

  • Add the m flag if ^ and $ should work on every line of a multi-line text.
  • A dot does not match line breaks unless you add the s flag.
  • Test the pattern on real text with the regex tester once the explanation matches what you meant.

Frequently asked questions

Which regex flavour does it explain?

JavaScript (ECMAScript), as used by RegExp in browsers and Node.js. Most of the syntax is shared with PCRE, Python and Java, but details differ: for example \w and \d match only ASCII in JavaScript even with the u flag, and there is no possessive quantifier or \A.

Can I paste /pattern/flags?

Yes. A pattern that starts with / and ends with / plus letters is read as a regex literal, and its flags are used instead of the Flags box.

Why is \d explained as only 0–9?

In JavaScript \d is exactly [0-9] and \w is [A-Za-z0-9_], with or without the u flag. To match digits or letters of other scripts use \p{Nd} or \p{L} with the u flag.

What does greedy or lazy mean?

A greedy quantifier (+, *, {2,}) takes as many repetitions as it can and gives some back only if the rest of the pattern fails. Adding ? (+?, *?) makes it lazy: it takes as few as possible and adds more only when needed.

What can it not explain?

Legacy octal escapes such as \07 and the set operations of the v flag (nested classes, && and --) are refused with a message. The pattern is also compiled by your browser, so anything JavaScript rejects is reported.

More in Developer

All tools in this category: Developer ·Updated November 4, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.