package containers

  1. Overview
  2. Docs
On This Page
  1. Copying functions
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module CCStringLabels.SplitSource

Sourcetype drop_if_empty = {
  1. first : bool;
  2. last : bool;
}

Specification of what to do with empty blocks, as in split ~by:"-" "-a-b-".

  • {first=false; last=false} will return ""; "a"; "b"; ""
  • {first=true; last=false} will return "a"; "b" ""
  • {first=false; last=true} will return ""; "a"; "b"
  • {first=true; last=true} will return "a"; "b"

The default value of all remaining functions is Drop_none.

  • since 1.5
Sourceval no_drop : drop_if_empty

Do not drop any group, even empty and on borders.

  • since 1.5
Sourceval list_ : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) list

Split the given string along the given separator by. Should only be used with very small separators, otherwise use Containers_string.KMP.

  • returns

    a list of slices (s,index,length) that are separated by by. String.sub can then be used to actually extract a string from the slice.

Sourceval gen : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) gen
Sourceval iter : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) iter
  • since 2.8
Sourceval seq : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) Seq.t

Renamed from std_seq since 3.0.

  • since 3.0
Copying functions

Those split functions actually copy the substrings, which can be more convenient but less efficient in general.

Sourceval list_cpy : ?drop:drop_if_empty -> by:string -> string -> string list
Sourceval gen_cpy : ?drop:drop_if_empty -> by:string -> string -> string gen
Sourceval iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iter
  • since 2.8
Sourceval seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t

Renamed from std_seq_cpy since 3.0.

  • since 3.0
Sourceval left : by:string -> string -> (string * string) option

Split on the first occurrence of by from the leftmost part of the string.

  • since 0.12
Sourceval left_exn : by:string -> string -> string * string

Split on the first occurrence of by from the leftmost part of the string.

  • raises Not_found

    if by is not part of the string.

  • since 0.16
Sourceval right : by:string -> string -> (string * string) option

Split on the first occurrence of by from the rightmost part of the string.

  • since 0.12
Sourceval right_exn : by:string -> string -> string * string

Split on the first occurrence of by from the rightmost part of the string.

  • raises Not_found

    if by is not part of the string.

  • since 0.16
OCaml

Innovation. Community. Security.