Fast algorithm for searching for substrings in a string

Read up on the Aho-Corasick algorithm and the Rabin-Karp algorithm.

If the input is not too large, you don’t want to repeat the search many times and you do not have many patterns, it might be a good idea to use a single pattern algorithm several times. The Wikipedia article on search algorithms gives many algorithms with running and preprocessing times.

Implementations:

  • https://hkn.eecs.berkeley.edu/~dyoo/java/index.html
  • http://algs4.cs.princeton.edu/53substring/RabinKarp.java.html
  • https://github.com/hankcs/AhoCorasickDoubleArrayTrie
  • https://github.com/RokLenarcic/AhoCorasick
  • https://github.com/robert-bor/aho-corasick

Presentations:

  • http://www.slideshare.net/taka111/ahocorasick-string-matching-algorithm-15078438

Leave a Comment

tech