Regex module

captures

procedureextension2 overloadsSource

The leftmost match at or after start, with where each group matched. Read the groups with group and span.

Example↗
Regex :: #import "Extensions/Regex";

re, _ := Regex.compile("(?<key>[a-z]+)=(?<value>[0-9]+)");
caps, found := Regex.captures(*re, "retries=3");
assert(found);
key, _ := Regex.group(caps, "key");
assert(key == "retries");
Regex.free_regex(*re);
captures :: (re: *Regex, text: string, start := 0) -> (Captures, bool)

Parameters

re: *Regex
text: string
start := 0

Returns

bool
captures :: ($R: Type, text: string, start := 0) -> (R.Groups, bool)

The leftmost match at or after start, with its named groups parsed. False if there is no match, or a number does not fit its field.

Parameters

$R: Type
text: string
start := 0

Returns

R.Groups
bool
Example↗
Regex :: #import "Extensions/Regex";
Pair :: Regex.Static("(?<key>[a-z]+)=(?<value>[0-9]+)");

pair, ok := Regex.captures(Pair, "  retries=3");
assert(ok && pair.key == "retries" && pair.value == 3);

See also