Module Core_string


module Core_string: sig .. end
An extension of the standard StringLabels. If you open Core.Std, you'll get these in the String module.

type t = string 
include Binable.S
include Comparable.S
include Container.S0
include Hashable.S
include Setable.S
include Sexpable.S
include Stringable.S
val length : string -> int
val get : string -> int -> char
val set : string -> int -> char -> unit
val create : int -> string
val make : int -> char -> string
val copy : string -> string
val sub : string -> pos:int -> len:int -> string
val fill : string -> pos:int -> len:int -> char -> unit
val blit : src:t ->
src_pos:int -> dst:t -> dst_pos:int -> len:int -> unit
val concat : sep:t -> string list -> string
val escaped : string -> string
val index : string -> char -> int
val rindex : string -> char -> int
val index_from : string -> int -> char -> int
val rindex_from : string -> int -> char -> int
val contains : string -> char -> bool
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val compare : string -> string -> int
val init : int -> f:(int -> char) -> t
val unescaped : ?strict:bool -> t -> t
unescaped s is the inverse operation of escaped: it takes a string where all the special characters are escaped following the lexical convention of OCaml and returns an unescaped copy. The strict switch is on by default and makes the function treat illegal backslashes as errors. When strict is false every illegal backslash except escaped numeral greater than 255 is copied literally. The aforementioned numerals still raise errors. Thsi mimics the behaviour of the ocaml lexer.
val unescaped_res : ?strict:bool ->
t -> (t, int * t) Result.t
Same as unescaped but instead of raising Failure _ returns an error message with the position in the string in case of failure.
val slice : string -> int -> int -> string
slice s start stop gets a slice of s between start and stop where * start and stop are normalized.
val nget : string -> int -> char
nget s i Gets the char at normalized position i in s.
val nset : string -> int -> char -> unit
nset s i c Sets the char at normalized position i to c.
val check_suffix : string -> string -> bool
check_suffix s suff returns true if the string s ends with the suffix suff
val check_prefix : string -> string -> bool
check_prefix s pref returns true if the string s starts with the prefix pref
val split2_exn : string -> char -> string * string
if string contains the character char, then split2_exn string char returns a pair containing string split around the first appearance of char (from the left)
Raises Not_found When char cannot be found in string
val rsplit2_exn : string -> char -> string * string
if string contains the character char, then rsplit2_exn string char returns a pair containing string split around the first appearance of char (from the right)
Raises Not_found When char cannot be found in string
val split2 : string -> char -> (string * string) option
split2 line delim optionally returns line split into two strings around the * first appearance of delim from the left
val rsplit2 : string -> char -> (string * string) option
rsplit2 line delim optionally returns line split into two strings around the * first appearance of delim from the right
val split_on_char : string -> char -> string list
split_on_char str delim
Returns a list of all substrings of str that are separated by delim.
val split_on_pipe : string -> string list
split_on_pipe str
Returns a list of all substrings of str that are separated by '|'.
val split_on_dot : string -> string list
split_on_dot str
Returns a list of all substrings of str that are separated by '.'.
val split_on_comma : string -> string list
split_on_comma str
Returns a list of all substrings of str that are separated by ','.
val split_on_chars : t -> char list -> t list
split_on_chars str delims
Returns a list of all substrings of str that are separated by any number of the chars from delims
val findi : string -> f:(int -> char -> bool) -> int option
findi string ~f returns the index i of the first character in t satisfying f i t.[i].
val findi : string -> f:(int -> char -> bool) -> int option
rfindi string ~f returns the index i of the last character in t satisfying f i t.[i].
val lstrip : string -> string
lstrip str returns a new string with consecutive white space (tabs, spaces, newlines, and carriage returns) stripped from the beginning of str.
val rstrip : string -> string
rstrip str returns a new string with consecutive white space (tabs, spaces, newlines, and carriage returns) stripped from the end of str.
val strip : string -> string
strip str returns a new string with consecutive white space (tabs, spaces, newlines, and carriage returns) stripped from the beginning and end of str.
val map : f:(char -> char) -> string -> string
map f s applies f to each character in s, and returns the resulting string.
val translate : f:(char -> string) -> string -> string
Like map, but allows replacement of a single character with zero or two or more characters.
val tr : target:char -> replacement:char -> string -> string
tr target replacement s replaces every instance of target in s with replacement.
val chop_suffix : t -> t -> t
drop_suffix t suff returns a copy t without the trailing suff
Raises Invalid_argument is suff is not a suffix t
val chop_prefix : t -> t -> t
drop_prefix t suff returns a copy t without the trailing pref
Raises Invalid_argument is pref is not a suffix t
val keep_suffix_n : string -> int -> string
keep_suffix_n string n returns the suffix of t of length n
val keep_prefix_n : string -> int -> string
keep_prefix_n string n returns the prefix of t of length n
val drop_suffix_n : string -> int -> string
drop_suffix_n string n drops the suffix of t of length n
val drop_prefix_n : string -> int -> string
drop_prefix_n string n drops the prefix of t of length n
val concat_array : sep:string -> string array -> string
concat_array sep ar like String.concat, but operates on arrays
val hash : string -> int
slightly faster hash function on strings
val equal : string -> string -> bool
fast equality function on strings, doesn't use compare_val
val pp : Format.formatter -> string -> unit
This has to be public for interactive top-levels.
val is_empty : string -> bool
is_empty t returns true iff t is empty (i.e. its length is 0).
module Infix: sig .. end
val of_char : char -> t