Oct-22-2019, 12:16 PM
(This post was last modified: Oct-22-2019, 12:17 PM by Gribouillis.)
You could use
more_itertools.last()
>>> import re >>> from more_itertools import last >>> p = re.compile(r'foo(.+?)bar') # <--- note the ? for the non greedy version of + >>> s = 'foo123bar...foo789bar' >>> match = last(p.finditer(s)) >>> match.group(1) '789'