match()
Returns whether any part of the string matches the regular expression.
Syntax
match(VAL_EXPR, REGEX)
Required Parameter
VAL_EXPR
- Expression to be evaluated. If the value is not a string, it converts the value to a string and then compares it with
REGEX
. REGEX
- Regular expression to compare to the
VAL_EXPR
value by enclosing it in a pair of double quotes (" "
). If the expression isnull
, the function returnsfalse
.
Usage
json "{}"
| eval match=match("8 miles", "\\d+ [a-z]+") => true
json "{}"
| eval match=match(" 8 miles ", "^\\d+ [a-z]+$") => false
json "{}"
| eval match=match("sample", "\\d+ [a-z]+") => false
json "{}"
| eval match=match(123, "\\d+") => true
json "{}"
| eval match=match(null, "\\d+") => false