things such as footnotes, list-numbers or other markers, embedded images, and so on. Many symbol systems include characters that are synonymous (at least for some purposes): Latin-based alphabets distinguish lower-case from upper-case, but for many purposes string search is expected to ignore the distinction. Many languages include ligatures, where one composite character is equivalent to two or more other characters. Many writing systems involve diacritical marks such as accents or vowel points, which may vary in their usage, or be of varying importance in matching. DNA sequences can involve non-coding segments which may be ignored for some purposes, or polymorphisms that lead to no change in the encoded proteins, which may not count as a true difference for some other purposes. Some languages have rules where a different character or form of character must be used at the start, middle, or end of words. Finally, for strings that represent natural language, aspects of the language itself become involved. For example, one might wish to find all occurrences of a "word" despite it having alternate spellings, prefixes or suffixes, etc. Another more complex type of search is regular expression searching, where the user constructs a pattern of characters or other symbols, and any match to the pattern should fulfill the search. For example, to catch both the American English word "color" and the British equivalent "colour", instead of searching for two different literal strings, one might use a regular expression such as: colou?r where the "?" conventionally makes the preceding character ("u") optional. This article mainly discusses algorithms for the simpler kinds of string searching. A similar problem introduced in the field of bioinformatics and genomics is the maximal exact matching (MEM). Given two strings, MEMs are common substrings that cannot be extended left or right without causing a mismatch. Examples of search algorithms Naive string search A simple and inefficient way to see where one string occurs inside another is to check at each index, one by one. First, we see if there's a copy of the needle starting at the first character of the haystack; if not, we look to see if there's a copy of the needle starting at the second character of the haystack, and so forth. In the normal case, we only have to look at one or two characters for each wrong position to see that it is a wrong position, so in the average