Regex module

find

procedureextension2 overloadsSource

The leftmost match at or after byte start.

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

re, _ := Regex.compile("[0-9]+");
match, found := Regex.find(*re, "room 101, floor 3");
assert(found && match.text == "101" && match.start == 5);
Regex.free_regex(*re);
find :: (re: *Regex, text: string, start := 0) -> (Match, bool)

The leftmost match at or after byte start.

Parameters

re: *Regex
text: string
start := 0
the byte offset to begin at. Anchors and \b still see the text before it.

Returns

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

re, _ := Regex.compile("[0-9]+");
match, found := Regex.find(*re, "room 101, floor 3");
assert(found && match.text == "101" && match.start == 5);
Regex.free_regex(*re);
find :: ($R: Type, text: string, start := 0) -> (Match, bool)

The leftmost match of the static pattern at or after start.

Parameters

$R: Type
text: string
start := 0

Returns

bool
Example↗
Regex :: #import "Extensions/Regex";
Digits :: Regex.Static("[0-9]+");

match, found := Regex.find(Digits, "room 101");
assert(found && match.text == "101");

See also