Module Regexp.Result

Matching results.

This handles the weird array returned by exec or match'.

type t

The type for regular expression matching results.

val input : t -> Jstr.t

input r is the string that was matched against.

val match' : t -> Jstr.t

match' r is the matched string.

val start_index : t -> int

start_index r is the index of the start of match' in input.

val stop_index : t -> int

stop_index r is the index after the end of match'. The last character of match' is at stop_index r - 1 in input.

val fold_groups : (Jstr.t -> 'a -> 'a) -> t -> 'a -> 'a

fold_groups f r acc folds f over the content of all capturing groups (named included) in r starting with acc. This is acc if there is no group.

val fold_group_indices : (start:int -> stop:int -> 'a -> 'a) -> t -> 'a -> 'a

fold_group_indices f r acc is like fold_groups but f is given the start and stop index of the group which indicate it spans the indices [start;stop-1] of input.

Warning. The regexp needs the d flag for this to yield results otherwise the function simply returns acc.

val fold_named_groups : (name:Jstr.t -> Jstr.t -> 'a -> 'a) -> t -> 'a -> 'a

fold_named_groups f r acc folds f over the content of named capturing groups in r starting with acc.

val fold_named_group_indices : (name:Jstr.t -> start:int -> stop:int -> 'a -> 'a) -> t -> 'a -> 'a

fold_named_group_indices f r acc is like fold_named_groups but f is given the start and stop index of the group which indicate it spans the indices [start;stop-1] of input.

Warning. The regexp needs the d flag for this to yield results otherwise the function simply returns acc.