← Guide List GUIDE
Understand the difference between *, +, {n,m} and adding a ?.

Quantifiers specify how many times the preceding element repeats. * is zero or more, + is one or more, and ? is zero or one. Use {n} for an exact count and {n,m} for a range. For example, \d{3} is exactly three digits.

By default quantifiers are greedy. That is, they try to consume as much as possible. Applying <.*> to <a>b<c> grabs everything from the first < to the last > in one go.

Adding ? after a quantifier makes it lazy matching. <.*?> consumes as little as possible, catching only <a>. This difference is decisive when pulling out content between tags or quotes one at a time.

Patterns often behave unexpectedly because of greediness or laziness. If your result is caught too broadly, think of a lazy quantifier or a negated character class (such as [^>]).