Regex¶
Import: import system.text;
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
Regex¶
A compiled regular expression. Use Regex.compile to report invalid patterns.
compile¶
Compiles a pattern with optional flags, returning an error for invalid patterns.
public static fun compile(
pattern: string,
flags: RegexFlags = RegexFlags.None
): Result<Regex, RegexError>
test¶
Returns whether the regular expression matches anywhere in input.
replace¶
Replaces matching text. Replaces every match with Global; otherwise replaces only the first.
match¶
Returns complete matches with Global, or the first match followed by its capture groups otherwise. Returns an empty array when unmatched.
match_info¶
Returns the first match and its named and numbered capture groups, or None when unmatched.