Module CCStringLabels.Split
type drop_if_empty={first : bool;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
val no_drop : drop_if_emptyno_dropdoes not drop any group, even empty and on borders.- since
- 1.5
val list_ : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) listlist_ ?drop ~by ssplits the given stringsalong the given separatorby. Should only be used with very small separators, otherwise useContainers_string.KMP.- returns
a
listof slices(s,index,length)that are separated byby.String.sub can then be used to actually extract a string from the slice.
- raises Failure
if
by = "".
val gen : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) gengen ?drop ~by ssplits the given stringsalong the given separatorby. Returns agenof slices.
val iter : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) iteriter ?drop ~by ssplits the given stringsalong the given separatorby. Returns aniterof slices.- since
- 2.8
val seq : ?drop:drop_if_empty -> by:string -> string -> (string * int * int) Stdlib.Seq.tseq ?drop ~by ssplits the given stringsalong the given separatorby. Returns aSeq.tof slices. Renamed fromstd_seqsince 3.0.- since
- 3.0
Copying functions
Those split functions actually copy the substrings, which can be more convenient but less efficient in general.
val list_cpy : ?drop:drop_if_empty -> by:string -> string -> string listlist_cpy ?drop ~by ssplits the given stringsalong the given separatorby. Returns alistof strings.
val gen_cpy : ?drop:drop_if_empty -> by:string -> string -> string gengen_cpy ?drop ~by ssplits the given stringsalong the given separatorby. Returns agenof strings.
val iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iteriter_cpy ?drop ~by ssplits the given stringsalong the given separatorby. Returns aniterof strings.- since
- 2.8
val seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Stdlib.Seq.tseq_cpy ?drop ~by ssplits the given stringsalong the given separatorby. Returns aSeq.tof strings. Renamed fromstd_seq_cpysince 3.0.- since
- 3.0
val left : by:string -> string -> (string * string) optionleft ~by ssplits on the first occurrence ofbyfrom the leftmost part of the strings.- since
- 0.12
val left_exn : by:string -> string -> string * stringleft_exn ~by ssplits on the first occurrence ofbyfrom the leftmost part of the strings.- raises Not_found
if
byis not part of the strings.
- since
- 0.16