Greedy and lazy quantifiers
By default quantifiers are greedy: they consume as much as possible and then give characters back only if the rest of the pattern fails. This is the single most common source of a pattern that matches far more than intended.
Adding a question mark after a quantifier makes it lazy, taking as little as possible and expanding only when needed.
text: <b>bold</b> and <i>italic</i>
<.+> greedy → <b>bold</b> and <i>italic</i>
<.+?> lazy → <b>
[^>]+ better → <b>The third form is usually best. Rather than relying on laziness, describe what the content cannot contain. It states the intent directly and does not backtrack.