Problem Statement
How do you make a quantifier non-greedy in Python regex?
Explanation
Adding question mark to star, plus, or brace quantifiers switches them to the shortest match. For example, star question matches as little as possible.
This is useful for extracting the smallest block between tags or quotes.
Code Solution
SolutionRead Only
import re
re.findall('<p>.*?</p>', html, flags=re.S)Practice Sets
This question appears in the following practice sets:
