NewRegexpBoolean returns a Boolean that compares values that must be a stringy the given regexp.
(re *regexp.Regexp)
| 242 | // NewRegexpBoolean returns a Boolean that compares values that must |
| 243 | // be a stringy the given regexp. |
| 244 | func NewRegexpBoolean(re *regexp.Regexp) Boolean { |
| 245 | return func(val super.Value) super.Value { |
| 246 | if val.IsNull() { |
| 247 | return super.Null |
| 248 | } |
| 249 | v := false |
| 250 | if val.IsString() { |
| 251 | v = re.Match(val.Bytes()) |
| 252 | } |
| 253 | return super.NewBool(v) |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | func CompareNull(op string) (Boolean, error) { |
| 258 | return func(val super.Value) super.Value { |