On Wed, Dec 4, 2019, at 11:05, Guido van Rossum wrote:
Not so fast. re.search() returns a Match object, while re.finditer() and re.findall() return strings. For people who are just interested in strings, the Match object is just a distraction. I think I am +1 on adding re.findfirst() as proposed by the OP.
Er, findall returns strings, but finditer returns match objects. And as a side note, PEP 505 would allow the case of wanting the string or None to be written as re.search(...)?.group(0).
(Since findall returns a list, it can be written as ....findall(...), which is much better than next(iter(....findall(...))).)