expr-lang / expr

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

Support matches for bytes #685

Open amikai opened 1 month ago

amikai commented 1 month 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 1 month ago

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