String matching is the problem of finding occurrences of one string (“pattern”, “needle”) in another (“text”, “haystack”).
There are two types of string matching:
- Exact
- Approximate
Exact string matching is the problem of finding occurrence(s) of a pattern string within another string or body of text. (NIST). For example, finding CGATCGATTA
in CTAGATCCTGCGATCGATTAAGCCTGA
.
A comprehensive online reference of string matching algorithms is Exact String Matching Algorithms by Christian Charras and Thierry Lecroq.
Approximate string matching, also called fuzzy string matching, searches for matches based on the edit distance between the pattern and the text.