package ppx_expect_nobase
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c4fdd0b6c620d2b357c07669aadf0a25f89d86b57f77e4b460179263e20bf084
sha512=c5398e16907ca57e7b811e72fd209f76c4e5f1fcac199995eb74af87de4edac3285d21cd015aab196f82b9303958fc6d3a94a27dce9b808f608f79e75976ea73
doc/ppx_expect_nobase.wrappers/Search_patternW/index.html
Module Search_patternWSource
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.
case_sensitive t returns whether t matches strings case-sensitively.
pos < 0 or pos >= length string result in no match (hence index returns None and index_exn raises).
may_overlap determines whether after a successful match, index_all should start looking for another one at the very next position (~may_overlap:true), or jump to the end of that match and continue from there (~may_overlap:false), e.g.:
index_all (create "aaa") ~may_overlap:false ~in_:"aaaaBaaaaaa" = [0; 5; 8]index_all (create "aaa") ~may_overlap:true ~in_:"aaaaBaaaaaa" = [0; 1; 5; 6; 7; 8]
E.g., replace_all internally calls index_all ~may_overlap:false.
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"