package re2

  1. Overview
  2. Docs
type 'a t
module Open_on_rhs_intf : sig ... end
include Core.Applicative.Let_syntax with type 'a t := 'a t with module Open_on_rhs_intf := Open_on_rhs_intf
module Let_syntax : sig ... end
include Open_on_rhs_intf.S with type 'a t := 'a t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
include Regex_parser_intf.S with type 'a t := 'a t
val compile : ?case_sensitive:Base.bool -> 'a t -> (Base.string -> 'a Base.option) Base.Staged.t
val run : ?case_sensitive:Base.bool -> 'a t -> Base.string -> 'a Base.option
val matches : ?case_sensitive:Base.bool -> 'a t -> Base.string -> Base.bool
val return : 'a -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val both : 'a t -> 'b t -> ('a * 'b) t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
val (<*) : 'a t -> unit t -> 'a t
val (*>) : unit t -> 'a t -> 'a t
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t
val all : 'a t list -> 'a list t
val all_unit : unit t list -> unit t
module Applicative_infix : sig ... end
val ignore_m : 'a t -> Base.unit t
val capture : Base.unit t -> Base.string t
val and_capture : 'a t -> ('a * Base.string) t
val fail : 'a t
val or_ : 'a t Base.list -> 'a t
val optional : ?greedy:Base.bool -> 'a t -> 'a Base.option t
val repeat : ?greedy:Base.bool -> ?min:Base.int -> ?max:Base.int Base.option -> Base.unit t -> Base.unit t
val times : Base.unit t -> Base.int -> Base.unit t
val string : Base.string -> Base.unit t
val any_string : Base.string t
val start_of_input : Base.unit t
val end_of_input : Base.unit t
module Char : sig ... end
module Decimal : sig ... end
val to_regex_string : _ t -> string

to_regex_string and to_re2 both forget what a 'a t knows about turning the matching strings into 'as

val to_re2 : ?case_sensitive:bool -> _ t -> Re2__.Regex.t
val of_re2 : Re2__.Regex.t -> string option array t

of_re2 r forgets the options that r was compiled with, instead using `Encoding_latin1 true, `Dot_nl true, and the case-sensitivity setting of the overall pattern. You can still try and use '(?flags:re)' Re2 syntax to set options for the scope of this regex.

The returned values are precisely the captures of the underlying regex, in order: note that unlike (say) Re2.Match.get_all, the whole match is *not* included (if you want that, just use capture). Named captures are not accessible by name.

OCaml

Innovation. Community. Security.