Skip to content

Commit

Permalink
Add examples for Re.split function
Browse files Browse the repository at this point in the history
Adds a few examples of using zero-length patterns as inputs to Re.split.  Examples are taken from the test suite.  Related to ocaml#119 and ocaml#120.
  • Loading branch information
mooreryan committed Feb 4, 2024
1 parent 55f8e7d commit 528a3fe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/core.mli
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ val split : ?pos:int -> ?len:int -> re -> string -> string list
# Re.split ~pos:3 regex "1,2,3,4. Commas go brrr.";;
- : string list = ["3"; "4. Commas go brrr."]
]}
Be careful when using [split] with zero-length patterns like [eol], [bow],
and [eow].
{[
# Re.split (Re.compile Re.eol) "a\nb";;
- : string list = ["a"; "\nb"]
# Re.split (Re.compile Re.bow) "a b";;
- : string list = ["a "; "b"]
# Re.split (Re.compile Re.eow) "a b";;
- : string list = ["a"; " b"]
]}
Note the position of the [\n] and space characters in the output.
*)

val split_gen : ?pos:int -> ?len:int -> re -> string -> string gen
Expand Down

0 comments on commit 528a3fe

Please sign in to comment.