“Fast Pattern Matching in Strings”, Donald Knuth, James H. Morris Junior, Vaughan R. Pratt1977-06-01 (; backlinks)⁠:

An algorithm is presented which finds all occurrences of one given string within another, in running time proportional to the sum of the lengths of the strings. The constant of proportionality is low enough to make this algorithm of practical use, and the procedure can also be extended to deal with some more general pattern-matching problems.

A theoretical application of the algorithm shows that the set of concatenations of even palindromes, ie. the language {ααR}✱, can be recognized in linear time.

Other algorithms which run even faster on the average are also considered.

[Keywords: pattern, string, text-editing, pattern-matching, trie memory, searching, period of a string, palindrome, optimum algorithm, Fibonacci string, regular expression, Boyer-Moore]