About Regex Explainer
A regular expression is a pattern that describes a set of strings. This explainer reads a pattern in JavaScript syntax from left to right and lists each token with its meaning: literal text, escapes such as \d and \w, character classes in square brackets, capture and named groups, lookaheads and lookbehinds, quantifiers, anchors, and alternation. The pattern is first compiled by your browser, so a syntax error is reported instead of explained.
How to use Regex Explainer
- Fill in "Regular expression" and "Flags".
- The result appears below and updates as you type.
- Copy the result with the copy button, or download it as a file where that is offered.
Questions about Regex Explainer
What is the difference between greedy and lazy quantifiers?
A greedy quantifier such as .* matches as much text as it can and gives characters back only if the rest of the pattern fails. Adding a question mark, as in .*?, makes it lazy: it matches as little as possible.
Runs in your browser. Page last updated .