E4172#
Compiler diagnostic name: invalid_regex_pattern.
Invalid regex pattern.
This error happens when a re"..." literal or a regex pattern used by
lexmatch does not follow MoonBit's regex syntax. Regex literals are checked at
compile time, so syntax errors, unsupported assertions, invalid ranges, and
duplicate capture names are reported before the program runs.
Erroneous example#
fn invalid_regex() -> Regex {
re"[a-z"
}
The character class starts with [, but never closes with ].
Suggestion#
Fix the regex syntax, or rewrite the pattern using a supported regex form.
fn valid_regex() -> Regex {
re"[a-z]"
}