Module Re2.Parser
include Re2__.Parser_intf.Parser
module Open_on_rhs_intf : sig ... endinclude Core_kernel.Applicative.Let_syntax with type 'a t := 'a t with module Open_on_rhs_intf := Open_on_rhs_intf
module Open_on_rhs_intf : sig ... endmodule Let_syntax : sig ... endinclude Open_on_rhs_intf.S with type 'a S.t := 'a t
type 'a t= 'a tA value of type
'a tis a regex that parses'as. The matching is implemented using Re2.UTF-8 is supported by Re2 but not by this module. This is because we want to use
charas a character type, but that's just wrong in a multibyte encoding.
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
val compile : ?case_sensitive:bool -> 'a t -> (string -> 'a option) Core_kernel.Staged.tcase_sensitivedefaults totrue.
val run : ?case_sensitive:bool -> 'a t -> string -> 'a optionval matches : ?case_sensitive:bool -> 'a t -> string -> boolval to_regex_string : _ t -> stringto_regex_stringandto_re2both forget what a'a tknows about turning the matching strings into'as
The applicative interface provides sequencing, e.g. both a b is a regex that parses an a followed by a b and returns both results in a pair.
include Core_kernel.Applicative.S with type 'a t := 'a t
val apply : ('a -> 'b) t -> 'a t -> 'b tval map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c tval map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd tval all : 'a t list -> 'a list tval all_unit : unit t list -> unit t
module Applicative_infix : Base__.Applicative_intf.Applicative_infix with type 'a t := 'a tval of_re2 : Regex.t -> string option array tof_re2 rforgets the options thatrwas 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 usecapture). Named captures are not accessible by name.
val ignore_m : _ t -> unit tignore_m tis a regex which matches the same strings thattmatches, but doesn't call functions on the captured submatches. Particularly, something likeignore (map (string "x") ~f:Int.of_string)won't raise an exception, because the int conversion is never attempted.
val and_capture : 'a t -> ('a * string) tand_capture treturns the string matched bytin addition to whatever it was already going to return.
val fail : 'a tRegex that matches nothing
val or_ : 'a t list -> 'a tval optional : ?greedy:bool -> 'a t -> 'a option tgreedydefaults to true. If false, the regexp will prefer not matching.
val repeat : ?greedy:bool -> ?min:int -> ?max:int option -> unit t -> unit trepeat ~min ~max tconstructs the regext{min,max}.mindefaults to0andmaxdefaults toNone(unbounded), so that just plainrepeat tis equivalent tot*.It would be better for
repeatto be'a t -> 'a list t, but the re2 library doesn't give you access to repeated submatches like that. Hence,repeatignores all submatches of its argument and does not call any callbacks that may have been attached to them, as if it hadignorecalled on its result.
val times : unit t -> int -> unit ttimes r nessentially constructs the regexr{n}. It is equivalent torepeat ~min:n ~max:(Some n) r.Compare with, say,
all (List.init n ~f:(fun _ -> r)), which constructs the regex rrr...r (with n copies of r) and has the type'a t -> 'a list t.
val string : string -> unit tval any_string : string tval start_of_input : unit tMatches empty string at the beginning of the text
val end_of_input : unit tMatches empty string at the end of the text
module Char : sig ... endmodule Decimal : sig ... end