strings.mli 2.12 KB
Newer Older
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
4
(*  Copyright 2010-2015   --   INRIA - CNRS - Paris-Sud University  *)
5 6 7 8
(*                                                                  *)
(*  This software is distributed under the terms of the GNU Lesser  *)
(*  General Public License version 2.1, with the special exception  *)
(*  on linking described in file LICENSE.                           *)
9
(*                                                                  *)
10 11
(********************************************************************)

12 13 14
(** {1 Additional Useful Functions on Character Strings} *)

(** {2 Wrappers for deprecated string functions of OCaml stdlib} *)
15 16 17 18 19

val create : int -> string
val copy : string -> string
val set : string -> int -> char -> unit

20
(** {2 Other useful functions on strings} *)
21

22
val rev_split : char -> string -> string list
23

24
val split : char -> string -> string list
25 26 27 28 29 30 31
(** [split c s] splits [s] into substrings, taking as delimiter the
    character [c], and returns the list of substrings.  An occurrence of
    the delimiter at the beginning or at the end of the string is
    ignored. *)

val bounded_split : char -> string -> int -> string list
(** [bounded_split c s n] do the same as [split c s] but splits into
David Hauzar's avatar
David Hauzar committed
32 33
    [n] substring at most.
    The concatenation of returned substrings is equal to the string s.*)
34

35 36 37 38
val join : string -> string list -> string
(** [join sep l] joins all the strings in [l] together, in the same
    order, separating them by [sep] *)

39 40 41 42 43
val ends_with : string -> string -> bool
(** test if a string ends with another *)

val pad_right : char -> string -> int -> string
(** chop or pad the given string on the right up to the given length *)
44 45 46 47 48 49 50

val has_prefix : string -> string -> bool
(** [has_prefix pref s] returns true if s [s] starts with prefix [pref] *)

val remove_prefix : string -> string -> string
(** [remove_prefix pref s] removes the prefix [pref] from [s]. Raises
    [Not_found if [s] does not start with [pref] *)