# E4220

Compiler diagnostic name: `regex_match_binding_not_supported`.

A `lexscan ... with longest` case uses a `before=` binding, which is not
available in longest-match mode.

For `String` and `StringView` inputs, first-match mode supports both `before=`
and `after=`. Longest-match mode starts at the beginning of the input, so it
supports `after=` but not `before=`.

## Erroneous example

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

## Suggestion

Remove `before=`, anchor the regex at `^`, and use `after=` when the unmatched
suffix is needed.

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