Module Brr.Regexp

RegExp objects and matching.

module Result : sig ... end

Matching results.

type t

The type for RegExp objects.

val escape : Jstr.t -> Jstr.t

escape s escapes the regexp syntax literals in s.

val create : ?flags:Jstr.t -> Jstr.t -> t

create ?flags s is the regexp object for s using flags if specified.

val exec : t -> Jstr.t -> Result.t option

exec r s executes regular expression r on s at index last_index.

val test : t -> Jstr.t -> bool

test r s tests s against r and returns true if it matches.

val match' : t -> Jstr.t -> Result.t option

match r s matches r against s. See also exec.

val fold_matches : t -> (Result.t -> 'a -> 'a) -> Jstr.t -> 'a -> 'a

fold_matches r f s acc folds f over the non-overlapping matches of r in s starintg with acc.

val replace : t -> by:Jstr.t -> Jstr.t -> Jstr.t

replace r ~by s replaces the first match of r by by in s.

val replace_all : t -> by:Jstr.t -> Jstr.t -> Jstr.t

replace_all r ~by s replaces all non-overlapping matches of r by by in s.

search r s is the first index of s that matches r or -1 if there is no match.

val split : ?limit:int -> t -> Jstr.t -> Jstr.t array

split r s splits s on delimiters matched by r.

Properties

val last_index : t -> int

last_index r is the index at which to start (sic) the next match.

val set_last_index : t -> int -> unit

set_last_index r i sets the last_index in r to i.

val dot_all : t -> bool

dot_all r is true if r has the s flag.

val flags : t -> Jstr.t

flags r are the flags of r.

val global : t -> bool

global r is true if r has the g flag.

val has_indices : t -> bool

has_indices r is true if r has the d flag.

val ignore_case : t -> bool

ignore_case r is true if r has the i flag.

val multiline : t -> bool

multiline r is true if r has the m flag.

val source : t -> Jstr.t

source r is the source text of r.

val sticky : t -> bool

sticky r is true if r has the y flag.

val unicode : t -> bool

unicode r is true if r has the u flag.

val unicode_sets : t -> bool

unicode_sets r is true if r has the v flag.