expr-lang / expr

Expression language and expression evaluation for Go
https://expr-lang.org
MIT License
6.35k stars 408 forks source link

Support matches for bytes #685

Open amikai opened 4 months ago

amikai commented 4 months ago

The matches operation currently only supports string types and uses regexp.MatchString under the hood. Is it possible to support regexp.Match when the left variable is a byte slice?

Currently, the string matches operation can support:

"123" matches "123"
a matches b
a matches "123"
"123" matches b

After adding support for byte slices, it should support the following scenarios (expr does not have a byte slice type):

a matches "123" (a is a byte slice in Go)
antonmedv commented 4 months ago

This is a good idea. Let's add support for []byte as well.