Module Regexp.ResultSource

Matching results.

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

Sourcetype t

The type for regular expression matching results.

Sourceval input : t -> Jstr.t

input r is the string that was matched against.

Sourceval match' : t -> Jstr.t

match' r is the matched string.

Sourceval start_index : t -> int

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

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.