substringsearch
Substring search is the problem of finding occurrences of a pattern string within a larger text. It is a core operation in text processing, search tools, compilers, and bioinformatics. The simplest method is the naive algorithm, which aligns the pattern at each position of the text and compares characters. This runs in O(nm) time in the worst case and uses constant extra space.
Efficient algorithms reduce the number of character comparisons. The Knuth–Morris–Pratt (KMP) algorithm uses a preprocessed table
Boyer–Moore is a highly effective approach for single-pattern search, employing bad-character and good-suffix heuristics to skip
Variants and considerations include case sensitivity, overlapping occurrences, streaming or online searching, and Unicode handling. Implementations