Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 527 Bytes

automaton_longest_prefix.rst

File metadata and controls

22 lines (18 loc) · 527 Bytes

longest_prefix(string) => integer

Return the length of the longest prefix of string that exists in the trie.

Examples

>>> import ahocorasick
>>> A = ahocorasick.Automaton()
>>> A.add_word("he", True)
True
>>> A.add_word("her", True)
True
>>> A.add_word("hers", True)
True
>>> A.longest_prefix("she")
0
>>> A.longest_prefix("herself")
4