Substring search and replace functions. They use the Knuth-Morris-Pratt algorithm (KMP) under the hood.
The functions in the Search_pattern module allow the program to preprocess the
searched pattern once and then use it many times without further allocations.
create pattern preprocesses pattern as per KMP, building an int array of
length length pattern. All inputs are valid.
pos < 0 or pos >= length string result in no match (hence index returns
None and index_exn raises).
Note that the result of replace_all pattern ~in_:text ~with_:r may still
contain pattern, e.g.
replace_all (create "bc") ~in:"aabbcc" ~with_:"cb" = "aabcbc"