Regex module

parse_into

procedureextensionSource

Like parse, into your own struct: each field takes the named group of the same name, and is a string, integer, float, bool (true / false) or enum (a member's name, any case). A field with no group or a group with no field is a compile error. False if the text does not match or a group's text does not fit its field.

Example↗
Regex :: #import "Extensions/Regex";
Time :: Regex.Static("(?<hour>[0-9]{2}):(?<minute>[0-9]{2})");

Clock :: struct { hour: int; minute: int; }

clock: Clock;
assert(Regex.parse_into(Time, "09:30", *clock));
assert(clock.hour == 9 && clock.minute == 30);
parse_into :: ($R: Type, text: string, out: *$T) -> bool

Parameters

$R: Type
text: string
out: *$T

Returns

bool

See also