
Predict
Greedy or Lazy?
Quantifiers like + and * are greedy: they grab as much text as
they can while still letting the overall match succeed. Putting a ?
after them (+?, *?) makes them lazy: they take as little as
possible.
import re
note = "<fuel> and <wick>"
greedy = re.findall(r"<.+>", note)
lazy = re.findall(r"<.+?>", note)
print(greedy, lazy)