Regular expression returning an index where match was found?

Robert Brewer fumanchu at
Thu Jul 8 17:25:30 CEST 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
Amor Ministries
fumanchu at

More information about the Python-list mailing list