Finding all regex matches by index?

Roy Smith roy at panix.com
Tue May 29 21:33:29 EDT 2012


I have a long string (possibly 100s of Mbytes) that I want to search for 
regex matches. re.finditer() is *almost* what I want, but the problem 
is that it returns matching strings. What I need is a list of offsets 
in the string where the regex matched. Thus:
s = "this is a string"
find("is", s) => [2, 5]
Is there anything that does this?


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /