Regex Explainer
Break a regular expression into pieces and explain what each one does in plain English.
Processing: This tool runs entirely in your browser. Your input and any file you open stay on your device — nothing is uploaded to a server.
How to use the regex explainer
- Paste the regular expression.
- Add its flags if it has any.
- Read the explanation piece by piece.
About this tool
Inheriting a regular expression someone else wrote is a common and unpleasant experience. This breaks one into its pieces and says what each does, in order, including the flags — which are easy to overlook and change the meaning of the whole pattern.
Distinctions that matter are called out specifically: greedy versus lazy quantifiers, capturing versus non-capturing groups, and lookahead versus lookbehind. Those four account for most of the confusion when a pattern nearly works.
Be clear about what this is. It explains each piece in the order it appears — a reading aid, not a parser. It will not tell you that two parts can never both match, or summarise the expression as a whole. It answers what each symbol is doing, which is usually the actual question.
Common uses
- Understanding a pattern found in an existing codebase.
- Learning regex syntax from real examples.
- Checking a pattern does what its author claimed.
Frequently asked questions
- What is the difference between greedy and lazy?
- A greedy quantifier takes as much as it can and gives back only if it must. A lazy one, written with a trailing ?, takes as little as possible. It is the usual reason .* swallows too much.
- What does (?: ) mean?
- A group that is not captured. It groups the pattern for a quantifier or alternation without producing a numbered result.
- Does this validate my pattern?
- It reports a syntax error if the pattern will not compile, and warns about the nested-quantifier shape that risks catastrophic backtracking. It does not check whether the pattern matches what you intended.
Related tools
Regex Tester
Test a regular expression against sample text with live highlighting and capture groups.
Regex Replace Tester
Test a regular expression replacement with capture groups and see the result live.
Regex Match Extractor
Pull every match out of text, with capture groups, named groups and positions.
Regex Escape
Escape text so it is treated as a literal inside a regular expression.