package re2

  1. Overview
  2. Docs
type t

A Match.t is the result of applying a regex to an input string

val sexp_of_t : t -> Sexplib0.Sexp.t
val get : sub:[ `Index of int | `Name of string ] -> t -> string option

If location information has been omitted (e.g., via ~sub), the error returned is Regex_no_such_subpattern, just as though that subpattern were never defined.

val get_exn : sub:[ `Index of int | `Name of string ] -> t -> string
val get_all : t Re2__.Regex.without_trailing_none -> string option array

get_all t returns all available matches as strings in an array. For the indexing convention, see comment above regarding sub parameter.

val get_pos_exn : sub:[ `Index of int | `Name of string ] -> t -> int * int

get_pos_exn ~sub t returns the start offset and length in bytes. Note that for variable-width encodings (e.g., UTF-8) this may not be the same as the character offset and character length.

OCaml

Innovation. Community. Security.