mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCString.mem
This commit is contained in:
parent
bca172a7a8
commit
1a73ad7e29
2 changed files with 11 additions and 0 deletions
|
|
@ -102,6 +102,8 @@ let find ?(start=0) ~sub s =
|
|||
with Exit ->
|
||||
!i
|
||||
|
||||
let mem ?start ~sub s = find ?start ~sub s >= 0
|
||||
|
||||
let rfind ~sub s =
|
||||
let n = String.length sub in
|
||||
let i = ref (String.length s - n) in
|
||||
|
|
|
|||
|
|
@ -108,6 +108,15 @@ val find : ?start:int -> sub:string -> string -> int
|
|||
find ~sub:"a" "_a_a_a_" = 1
|
||||
*)
|
||||
|
||||
val mem : ?start:int -> sub:string -> string -> bool
|
||||
(** [mem ~sub s] is true iff [sub] is a substring of [s]
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
(*$T
|
||||
mem ~sub:"bc" "abcd"
|
||||
not (mem ~sub:"a b" "abcd")
|
||||
*)
|
||||
|
||||
val rfind : sub:string -> string -> int
|
||||
(** Find [sub] in string from the right, returns its first index or [-1].
|
||||
Should only be used with very small [sub]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue