package stringext

  1. Overview
  2. Docs
Extra string functions for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

1.5.0.zip
sha256=fbfab294bdfe0dd840fe5d4a0d12319955094c75067bd5bb5dc4a34a71f18d13
md5=867263ea97532f150516677fa994cdf2

Description

Extra string functions for OCaml. Mainly splitting. All functions are in the Stringext module.

Published: 09 Aug 2017

README

Stringext -- Extra string functions fo OCaml

Extra string functions for OCaml. Mainly splitting. All functions are in the Stringext module. Here's a snippet of most useful functions out of the mli:

Api Documentation

(** string_after [s] [n] returns the substring of [s] that is after
    character [n] *)
val string_after : string -> int -> string

(** equivalent to [Str.quote] *)
val quote : string -> string

(** 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 *)
val split : ?max:int -> 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 *)
val full_split : string -> on:char -> string list

(** Trims spaces on the left of the string. In case no trimming is needed
    the same string is returned without copying *)
val trim_left : string -> string

(** 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 *)
val split_trim_left : string -> on:string -> trim:string -> string list

val of_char : char -> string

val of_list : char list -> string

val to_list : string -> char list

val to_array : string -> char array

val of_array : char array -> string

val find_from : ?start:int -> string -> pattern:string -> int option

val replace_all : string -> pattern:string -> with_:string -> string

val replace_all_assoc : string -> (string * string) list -> string

val 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.

    @raise Invalid_argument if [on] is the empty string. *)

val 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].

    @raise Invalid_argument if [on] is the empty string. *)

val chop_prefix : string -> prefix:string -> string option

val drop : string -> int -> string

val take : string -> int -> string

(** [trim_left_sub s ~pos ~len ~chars] Trim all characters inside [chars]
    from [s] starting from [pos] and up to [len] *)
val trim_left_sub : string -> pos:int -> len:int -> chars:string -> string

Dependencies (2)

  1. jbuilder >= "1.0+beta10"
  2. ocaml >= "4.02.3"

Dev Dependencies (2)

  1. qtest with-test & >= "2.2"
  2. ounit with-test

Used by (34)

  1. alcotest >= "0.4.3" & < "0.4.8"
  2. calculon
  3. cohttp >= "0.11.0"
  4. cohttp-curl
  5. cohttp-curl-async
  6. cohttp-curl-lwt
  7. conduit >= "0.6.0" & < "1.0.0"
  8. git >= "1.6.0" & < "1.8.0"
  9. github >= "0.8.2"
  10. github-unix
  11. gitlab
  12. gitlab-unix
  13. grpc-async
  14. grpc-eio
  15. grpc-examples
  16. grpc-lwt
  17. irmin >= "0.9.0" & < "0.12.0"
  18. iso-filesystem
  19. mirage-block-xen >= "1.4.0" & < "2.0.0"
  20. multipart-form-data
  21. opium >= "0.17.0" & < "0.18.0"
  22. otr = "0.2.0"
  23. podge >= "0.5" & < "0.8.0"
  24. protocol-9p < "0.7.2"
  25. rfc6287 < "1.0.1"
  26. rubytt
  27. satyrographos >= "0.0.2.7"
  28. soupault < "2.6.0"
  29. starterkit
  30. uri >= "1.5.0"
  31. uri-re
  32. usbmux < "1.2.0"
  33. vpnkit >= "0.2.0"
  34. xentropyd

Conflicts

None

OCaml

Innovation. Community. Security.