The Aho-Corasick algorithm is a string searching algorithm invented by Alfred V. Aho and Margaret J. Corasick searches the text for an element of finite set of patterns.

Informally, the algorithm constructs a search engine first and then uses it on raw text. In many cases, where the set of patterns is given in advance (e.g. computer virus database), the construction step could be performed only once and the compiled engine stored for later use.