Reference · reference
regex module
use regex matches regular expressions against strings, so a script does not have to shell out to grep or sed. config-weave registers it from wscript-std. Patterns use Rust regex syntax: no backreferences, no lookaround, and matching runs in linear time. No function returns a Result. An invalid pattern is a runtime fault that surfaces as the step's Error status, because patterns are literals in practice and a script has no way to recover from a bad one.
The pattern comes first
Every function takes (pattern, text). The two arguments have the same type, so swapping them compiles and then never matches.
is_match
is_match Whether the pattern matches anywhere in s.
find and find_all
find
find_all
find returns the first match, or None. find_all returns every non-overlapping match in order.
replace
replace Replaces every match with rep. Inside rep, $1 and $name expand to the capture groups of that match.
captures
captures
Returns the capture groups of the first match, with group 0, the whole match, first. A group that did not participate is the empty string. Returns None when nothing matches.
split
split
Splits s around every match.
use regex
let major = match captures Some => groups,
None => "0",
}