The regex
module
The regex
module provides a regular expression engine for Metis. It has the same semantics as Java’s regular expression engine.
Free functions
compile(regex: string): native
Compiles the given regular expression and returns a native object that represents the compiled regular expression. Raises RegexError
if the regular expression is invalid.
escape(string: string): string
Escapes the given string so that it can be used as a literal in a regular expression.
Member functions
match(self, string: string): list[string] | null
Returns the list of groups in the matched string if the regular expression matches the given string. Returns null
if the regular expression does not match the given string.
replace(self, string: string, replacement: string): string
Returns a copy of the given string with the first match of the regular expression replaced with the given replacement string.
split(self, string: string): list[string]
Splits the given string at the matches of the regular expression and returns the list of substrings.