Module Re2
include Regex
include Re2__.Regex_intf.S
Basic Types
include Bin_prot.Binable.S with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizerval bin_write_t : t Bin_prot.Write.writerval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : (int -> t) Bin_prot.Read.readerThis function only needs implementation if
texposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the varianttafterwards.
val bin_shape_t : Bin_prot.Shape.tval bin_writer_t : t Bin_prot.Type_class.writerval bin_reader_t : t Bin_prot.Type_class.readerval bin_t : t Bin_prot.Type_class.t
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> tval sexp_of_t : t -> Sexplib0.Sexp.t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_value
type regex= ttype id_t=[|`Index of int|`Name of string]Subpatterns are referenced by name if labelled with the
/(?P<...>...)/syntax, or else by counting open-parens, with subpattern zero referring to the whole regex.
val index_of_id_exn : t -> id_t -> intindex_of_id t idresolves subpattern names and indices into indices. *
module Options : sig ... endval create : ?options:Options.t -> string -> t Core_kernel.Or_error.tval create_exn : ?options:Options.t -> string -> t
include Core_kernel.Stringable with type t := t
val num_submatches : t -> intnum_submatches treturns 1 + the number of open-parens in the pattern.N.B.
num_submatches t == 1 + RE2::NumberOfCapturingGroups()becauseRE2::NumberOfCapturingGroups()ignores the whole match ("subpattern zero").
val pattern : t -> stringpattern treturns the pattern from which the regex was constructed.
val options : t -> Options.tval find_all : ?sub:id_t -> t -> string -> string list Core_kernel.Or_error.tfind_all t inputa convenience function that returns all non-overlapping matches oftagainstinput, in left-to-right order.If
subis given, and the requested subpattern did not capture, then no match is returned at that position even if other parts of the regex did match.
val find_all_exn : ?sub:id_t -> t -> string -> string listval find_first : ?sub:id_t -> t -> string -> string Core_kernel.Or_error.tfind_first ?sub pattern inputfinds the first match ofpatternininput, and returns the subpattern specified bysub, or an error if the subpattern didn't capture.
val find_first_exn : ?sub:id_t -> t -> string -> stringval find_submatches : t -> string -> string option array Core_kernel.Or_error.tfind_submatches t inputfinds the first match and returns all submatches. Element 0 is the whole match and element 1 is the first parenthesized submatch, etc.
val find_submatches_exn : t -> string -> string option arrayval matches : t -> string -> boolmatches pattern input- returns
true iff
patternmatchesinput
val split : ?max:int -> ?include_matches:bool -> t -> string -> string listsplit pattern input- returns
inputbroken into pieces wherepatternmatches. Subpatterns are ignored.
- parameter max
(default: unlimited) split only at the leftmost
maxmatches
- parameter include_matches
(default: false) include the matched substrings in the returned list (e.g., the regex
/[,()]/on"foo(bar,baz)"gives["foo"; "("; "bar"; ","; "baz"; ")"]instead of["foo"; "bar"; "baz"])If
tnever matches, the returned list hasinputas its one element.
val rewrite : t -> template:string -> string -> string Core_kernel.Or_error.trewrite pattern ~template inputis a convenience function forreplace: Instead of requiring an arbitrary transformation as a function, it accepts a template string with zero or more substrings of the form"\\n", each of which will be replaced by submatchn. For every match ofpatternagainstinput, the template will be specialized and then substituted for the matched substring.
Infix Operators
module Infix : sig ... endComplicated Interface
val sexp_of_without_trailing_none : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a without_trailing_none -> Ppx_sexp_conv_lib.Sexp.t
val without_trailing_none : 'a -> 'a without_trailing_noneThis type marks call sites affected by a bugfix that eliminated a trailing None. When you add this wrapper, check that your call site does not still work around the bug by dropping the last element.
module Match : sig ... endval get_matches : ?sub:id_t -> ?max:int -> t -> string -> Match.t list Core_kernel.Or_error.tget_matches pattern inputreturns all non-overlapping matches ofpatternagainstinput- parameter max
(default: unlimited) return only the leftmost
maxmatches
- parameter sub
(default: all) returned Match.t's will contain only the first
submatches.
val get_matches_exn : ?sub:id_t -> ?max:int -> t -> string -> Match.t listval to_sequence_exn : ?sub:id_t -> t -> string -> Match.t Core_kernel.Sequence.tval first_match : t -> string -> Match.t Core_kernel.Or_error.tfirst_match pattern input- returns
the first match iff
patternmatchesinput
val first_match_exn : t -> string -> Match.tval replace : ?sub:id_t -> ?only:int -> f:(Match.t -> string) -> t -> string -> string Core_kernel.Or_error.treplace ?sub ?max ~f pattern input- returns
an edited copy of
inputwith every substring matched bypatterntransformed byf.
- parameter only
(default: all) replace only the nth match
module Exceptions : sig ... endmodule Multiple : sig ... endmodule Parser : sig ... endmodule Std : sig ... endmodule Regex : sig ... end