Regular expression returning an index where match was found?
Robert Brewer
fumanchu at amor.org
Thu Jul 8 11:25:30 EDT 2004
Jon Nicoll wrote:
> myfunc("abc", "abcdefabcabc")
>
> would return (say) a list [0, 6, 9]
>
> I can't see a straightforward way of doing this from reading the
> Regular Expression HOWTO and the python docs; any
> pointers/suggestions?
Use finditer (which returns match objects), then match.start.
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
More information about the Python-list
mailing list