Efficient way of testing for substring being one of a set?

Dennis.Benzinger@gmx.net dennis.benzinger at gmx.net
Thu Apr 3 15:08:36 CEST 2008

On Apr 3, 1:37 pm, tinn... at isbd.co.uk wrote:
> What's the neatest and/or most efficient way of testing if one of a
> set of strings (contained in a dictionary, list or similar) is a
> sub-string of a given string?
> [...]

You could use the Aho-Corasick algorithm <http://en.wikipedia.org/wiki/
I don't know if there's a Python implementation yet.

Dennis Benzinger

More information about the Python-list mailing list