[regex] What do 'lazy' and 'greedy' mean in the context of regular expressions?

Greedy Quantifiers are like the IRS/ATO

If it’s there, they’ll take it all.

The IRS matches with this regex: .*

$50,000

This will match everything!

See here for an example: Greedy-example

Non-greedy quantifiers - they take as little as they can

If I ask for a tax refund, the IRS sudden becomes non-greedy, and they use this quantifier:

(.{2,5}?)([0-9]*) against this input: $50,000

The first group is non-needy and only matches $5 – so I get a $5 refund against the $50,000 input. They're non-greedy. They take as little as possible.

See here: Non-greedy-example.

Why bother?

It becomes important if you are trying to match certain parts of an expression. Sometimes you don't want to match everything.

Hopefully that analogy will help you remember!