Regex module

Static

structSource

A regex compiled while your program compiles: a type, made from a constant pattern.

ExampleOpen in playground ↗
Regex :: #import "Extensions/Regex";
Date :: Regex.Static("(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})");
date, ok := Regex.parse(Date, "2026-10-11");  // a Date.Groups: date.year is a u16

A bad pattern is a compile error, and the automata are built at compile time (big Unicode classes excepted: those are built on first use), so searching needs no setup. The same procedures as for a Regex take it in place of *re, and parse, parse_into and captures_into only take one of these. For a pattern known only at run time, use compile.

See also