Module StringextSource

Misc. string functions not found in the built in OCaml string module

Sourceval string_after : string -> int -> string

string_after s n returns the substring of s that is after character n

Sourceval quote : string -> string

equivalent to Str.quote

Sourceval split : ?max:int -> string -> on:char -> string list

split ?max s ~on splits s on every on occurence upto max number of items if max is specified. max is assumed to be a small number if specified. To not cause stack overflows

Sourceval full_split : string -> on:char -> string list

full_split s ~on will split s on every occurence of on but will add the separators between the tokens. Maintains the invariant:

String.concat (full_split s ~on) =s

Sourceval trim_left : string -> string

Trims spaces on the left of the string. In case no trimming is needed the same string is returned without copying

Sourceval split_trim_left : string -> on:string -> trim:string -> string list

split_strim_left s ~on ~trim splits s on every character in on. Characters in trim are trimmed from the left of every result element

Sourceval of_char : char -> string
Sourceval of_list : char list -> string
Sourceval to_list : string -> char list
Sourceval to_array : string -> char array
Sourceval of_array : char array -> string
Sourceval find_from : ?start:int -> string -> pattern:string -> int option
Sourceval replace_all : string -> pattern:string -> with_:string -> string
Sourceval replace_all_assoc : string -> (string * string) list -> string
Sourceval cut : string -> on:string -> (string * string) option

String.cut on s is either the pair Some (l,r) of the two (possibly empty) substrings of s that are delimited by the first match of the non empty onarator string on or None if on can't be matched in s. Matching starts from the beginning of s.

The invariant l ^ on ^ r = s holds.

Sourceval rcut : string -> on:string -> (string * string) option

String.rcut on s is like cut but the matching is done backwards starting from the end of s.

Sourceval chop_prefix : string -> prefix:string -> string option
Sourceval drop : string -> int -> string
Sourceval take : string -> int -> string
Sourceval trim_left_sub : string -> pos:int -> len:int -> chars:string -> string

trim_left_sub s ~pos ~len ~chars Trim all characters inside chars from s starting from pos and up to len