Source

spotlib / lib / xstring.mli

The default branch has multiple heads

Full commit
val is_prefix : ?from:int -> prefix:string -> string -> bool
val is_postfix : postfix:string -> string -> bool
val index_from_to : string -> int -> int -> char -> int option
val index_string_from : string -> int -> string -> int (* may raise Not_found *)

val sub_from_to : string -> int -> int -> string

val chop_newline : string -> string
(** [chop_newline s] returns the string [s] w/o the newline chars at the end.
    [chop_newline "hello\r\n" = "hello"]
    [chop_newline "hello\n" = "hello"]
    [chop_newline "hello" = "hello"]
*)

val make1 : char -> string
(** [make1 = String.make 1] *) 

val split_by_newline : string -> string list
val split : (char -> bool) -> string -> string list

module Set : Xset.S with type elt = String.t

module Open : sig
  val chop_newline : string -> string
  val split_by_newline : string -> string list
end

(** Haskelish string sub *)
val split_at : int -> string -> string * string
val take : int -> string -> string
val drop : int -> string -> string

(** Optionalized *)
val index_opt : string -> char -> int option

val scani_left : 
  (int -> 'a -> char -> [< `Continue of 'a | `Stop of 'a]) 
  -> 'a -> ?from:int -> ?to_:int -> string -> 'a

val foldi_left : 
  (int -> 'a -> char -> [< `Continue of 'a | `Stop of 'a]) 
  -> 'a -> string -> 'a