# 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

```{literalinclude} /sources/error_codes/4172_error/top.mbt
:language: moonbit
```

The character class starts with `[`, but never closes with `]`.

## Suggestion

Fix the regex syntax, or rewrite the pattern using a supported regex form.

```{literalinclude} /sources/error_codes/4172_fixed/top.mbt
:language: moonbit
```
