
"Mathias" == Mathias Panzenböck <grosser.meister.morti@gmx.net> writes: Mathias> I would expect such a method to return the index where one of the Mathias> given strings was found. Or maybe a tuple: (start, end) or a Mathias> tuple: (start, searchstring).
It could do something like that if you passed an argument telling it to quit on the first match. But that makes the return type depend on the passed arg, which I guess is not good. We'd already be doing that if we returned a dict, but this would return either a tuple or a dict. You could drop the dict idea altogether, but you need to consider what to do if many (probably different) patterns match, all starting at the same location in the string. For this reason alone I don't think returning a (start searchstring) tuple is sufficient. Given that Aho & Corasick find everything you could want to know (all matches of all patterns), and that they do it in linear time, it doesn't seem right to throw this information away - especially after going to the trouble of building and walking the trie. Terry