# E4218

Compiler diagnostic name: `lexscan_pattern_not_anchored`.

A `lexscan` regex pattern is not anchored where anchoring is required.

Patterns used with the `longest` strategy must start at the beginning of the
input. Anchor each such regex with `^`.

## Erroneous example

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

## Suggestion

Add `^` to the start of the regex. Add `$` as well only when the case must
consume the whole input.

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