Find first matching substring

John Machin sjmachin at
Sat Jul 18 03:54:11 CEST 2009

On Jul 18, 2:11 am, Eloff <dan.el... at> wrote:
> Almost every time I've had to do parsing of text over the last 5 years
> I've needed this function:
> It finds the first matching substring in the target string, if there
> is more than one match, it returns the position of the match that
> occurs at the lowest index in the string.

(1)"sub0|sub1|...", ...)
(2) google "Aho Corasick Python" (one result should be a thread in
this newsgroup within the last week)

More information about the Python-list mailing list