Regular expression returning an index where match was found?

Jon Nicoll jkn at nicorp.f9.co.uk
Mon Jul 12 19:04:02 CEST 2004


Thanks for the pointers - I realised that finditer() would do what I
wanted about 3 minutes after posting ... a terrific use of the faclity
;-)

    Cheers
    Jon N

"Robert Brewer" <fumanchu at amor.org> wrote in message news:<mailman.124.1089300588.5135.python-list at python.org>...
> 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