Regex Explainer
Paste a regular expression and read what each token does in plain English: groups, classes, quantifiers, anchors, lookarounds and backreferences.
Free · No sign-up · Your inputs stay in your browser
Input
Explain a regular expression
Output
15 parts
| Token | Matches |
|---|---|
| ^ | the start of the string (or line, with the m flag) |
| (?<user> | start capturing group 1, named user |
| [\w.+-] | one of word characters.+- |
| + | repeat the previous item one or more times |
| ) | end the group |
| @ | the literal character @ |
| ( | start capturing group 2 |
| [a-z0-9-] | one of a-z0-9- |
| + | repeat the previous item one or more times |
| \. | a literal . |
| ) | end the group |
| + | repeat the previous item one or more times |
| [a-z] | one of a-z |
| {2,} | repeat the previous item 2 or more times |
| $ | the end of the string (or line, with the m flag) |
Explains JavaScript and PCRE syntax token by token; indentation shows group nesting. Flavour differences matter at the edges: possessive quantifiers and (?P<name>) are PCRE (PHP) only, and lookbehind needs a modern engine.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Reading someone else's regex
A regex in a codebase rarely comes with a comment, and the hard part is usually the nesting: which quantifier applies to which group, and where an alternation starts and ends. Breaking it into one row per token makes that visible. To see what it actually matches, run it on real input in the regex tester.
Flavours differ at the edges
The syntax explained here is shared by JavaScript and PCRE, which PHP's preg functions use. Possessive quantifiers such as a++ and named groups written (?P<name>) are PCRE only, and lookbehind needs a modern engine. Python's re module is close but has its own differences, listed in the re documentation.