# E4181

Compiler diagnostic name: `named_capture_in_regex_literal_used_in_lex_is_not_supported`.

Named capture groups are not supported in regex literals used by `lexmatch`.

`lexmatch` can bind parts of a regex pattern through positional binders in the
lex pattern. Named capture groups inside the regex itself are rejected because
they are not part of the supported lex pattern binding model.

## Erroneous example

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

The regex contains the named capture group `(?<word>...)`.

## Suggestion

Use a normal regex group and bind the matched rest through the surrounding lex
pattern when needed.

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