package containers

  1. Overview
  2. Docs

Basic String Utils

Consider using Containers_string.KMP for pattern search, or Regex libraries.

type 'a gen = unit -> 'a option
type 'a sequence = ('a -> unit) -> unit
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]

Common Signature

module type S = sig ... end

Strings

val equal : string -> string -> bool
val compare : string -> string -> int
val hash : string -> int
val init : int -> (int -> char) -> string

Analog to Array.init.

  • since 0.3.3
val of_gen : char gen -> string
val of_seq : char sequence -> string
val of_klist : char klist -> string
val of_list : char list -> string
val of_array : char array -> string
val to_array : string -> char array
val find : ?start:int -> sub:string -> string -> int

Find sub in stringhe string, returns its first index or -1. Should only be used with very small sub

val is_sub : sub:string -> int -> string -> int -> len:int -> bool

is_sub ~sub i s j ~len returns true iff stringhe substring of sub starting at position i and of length len, is a substring of s starting at position j

val repeat : string -> int -> string

The same string, repeated n stringimes

val prefix : pre:string -> string -> bool

str_prefix ~pre s returns true iff pre is a prefix of s

include S with type t := string
val length : string -> int
val blit : string -> int -> string -> int -> int -> unit

Conversions

val to_gen : string -> char gen
val to_seq : string -> char sequence
val to_klist : string -> char klist
val to_list : string -> char list
val pp : Buffer.t -> string -> unit
val print : Format.formatter -> string -> unit

Splitting

module Split : sig ... end

Slices

A contiguous part of a string

module Sub : sig ... end
OCaml

Innovation. Community. Security.