package ppx_expect_nobase

  1. Overview
  2. Docs
Cram like framework for OCaml (with stripped dependencies)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ppx_expect_nobase-0.17.3.0.tbz
sha256=ff2cb97c867a4bd3a0778ff0924c1cb8a82c7c531f81f2b0aa220b7c29758e40
sha512=3eae2efe081aeed87d44d46f960a66744ed6d90c78f07ba91639ff2694aea655d4b71c5865d97dd88c1681e3752b90c06c252595f67ff135fcce87c38085b81f

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.

Sourcetype t
Sourceval create : ?case_sensitive:bool -> string -> t

create pattern preprocesses pattern as per KMP, building an int array of length length pattern. All inputs are valid.

Sourceval pattern : t -> string

pattern t returns the string pattern used to create t.

Sourceval case_sensitive : t -> bool

case_sensitive t returns whether t matches strings case-sensitively.

Sourceval matches : t -> string -> bool

matches pat str returns true if str matches pat

Sourceval index : ?pos:int -> t -> in_:string -> int option

pos < 0 or pos >= length string result in no match (hence index returns None and index_exn raises).

Sourceval index_exn : ?pos:int -> t -> in_:string -> int
Sourceval index_all : t -> may_overlap:bool -> in_:string -> int list

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.

Sourceval replace_first : ?pos:int -> t -> in_:string -> with_:string -> string

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"
Sourceval replace_all : t -> in_:string -> with_:string -> string
Sourceval split_on : t -> string -> string list

Similar to String.split or String.split_on_chars, but instead uses a given search pattern as the separator. Separators are non-overlapping.