# E4176

Compiler diagnostic name: `invalid_lexmatch_target`.

Invalid `lexmatch` target.

`lexmatch` works on textual views. The target expression must have a type that
can be matched by regex patterns, such as `String` or `StringView`, instead of a
numeric, boolean, or other unrelated type.

## Erroneous example

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

The target is an `Int`, which cannot be consumed by `lexmatch`.

## Suggestion

Match a string-like value, or convert the input before using `lexmatch`.

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