JS: '<b>bold</b> and <b>more</b>'.match(/<b>.*<\/b>/)
JS: '<b>bold</b> and <b>more</b>'.match(/<b>.*?<\/b>/)
output
Greedy: "<b>bold</b> and <b>more</b>" (longest match)
Lazy: "<b>bold</b>" (shortest match)
Note Greedy quantifiers eat as much as possible, then backtrack. Lazy quantifiers match as little as possible, then expand. This distinction is critical when parsing HTML, quoted strings, or any delimited content. Always prefer lazy when you want the nearest closing delimiter.
Note The .*? idiom scans forward character by character until the following pattern matches. This is the standard approach for extracting content between delimiters. Be aware that .*? can still cause slowdowns on long strings with no match -- consider using negated character classes instead when possible.