20 chars · 1 line
8 chars · 1 line
20 chars · 1 line
8 chars · 1 line
Regex quantifier behavior
Greedy quantifiers consume as much text as possible while still allowing the pattern to succeed. That is why <.*> spans from the first < to the final > in the sample. Adding ? makes the quantifier lazy so Match All stops at the earliest closing delimiter each time. This tool is free to use. No account or payment is required.
Last updated
The dot still has the same character semantics. The extra ? changes how the quantifier expands while the engine searches for a successful match.
The greedy form spans all tags; the lazy form stops at each nearest >.
<.*><.*?>Common questions
Place ? after the quantifier, for example *?, +?, ??, or {m,n}?.
No. Choose the form whose stopping behavior matches the data and test representative edge cases.
For general HTML parsing, a parser is usually more appropriate. This example is about quantifier behavior with simple delimiters.
Debugging a specific Regex issue? Browse Regex troubleshooting.