Is there any better (and shorter) way to get index of a regex match in Python?
import re sstring = """ this is dummy text which starts with nothing and ends with something """ starts = re.finditer('start[s]?', sstring) ends = re.finditer('end[s]?', sstring) for m in starts: print (m.start()) for m in ends: print (m.end())
For me, there is only one
endsmatch in the string.