mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-20 18:10:07 +00:00
test cases for regexes in mlr filter
This commit is contained in:
parent
e9c50c2832
commit
bbddecf57c
4 changed files with 52 additions and 2 deletions
|
|
@ -816,8 +816,8 @@ static function_lookup_t FUNCTION_LOOKUP_TABLE[] = {
|
|||
{ FUNC_CLASS_MATH, "%", 2 , "Remainder; never negative-valued."},
|
||||
{ FUNC_CLASS_MATH, "**", 2 , "Exponentiation; same as pow."},
|
||||
|
||||
{ FUNC_CLASS_BOOLEAN, "=~", 2 , "String (left-hand side) matches regex (right-hand side) [under construction]."},
|
||||
{ FUNC_CLASS_BOOLEAN, "!=~", 2 , "String (left-hand side) does not match regex (right-hand side) [under construction]."},
|
||||
{ FUNC_CLASS_BOOLEAN, "=~", 2 , "String (left-hand side) matches regex (right-hand side), e.g. '$name =~ \"^a.*b$\"'."},
|
||||
{ FUNC_CLASS_BOOLEAN, "!=~", 2 , "String (left-hand side) does not match regex (right-hand side), e.g. '$name !=~ \"^a.*b$\"'."},
|
||||
{ FUNC_CLASS_BOOLEAN, "==", 2 , "String/numeric equality. Mixing number and string results in string compare."},
|
||||
{ FUNC_CLASS_BOOLEAN, "!=", 2 , "String/numeric inequality. Mixing number and string results in string compare."},
|
||||
{ FUNC_CLASS_BOOLEAN, ">", 2 , "String/numeric greater-than. Mixing number and string results in string compare."},
|
||||
|
|
|
|||
|
|
@ -1490,6 +1490,46 @@ mlr filter -v $x<$a*$b+-$c /dev/null
|
|||
- (operator):
|
||||
c (field_name).
|
||||
|
||||
mlr filter -v $x =~ "bcd" ./reg_test/input/regex.dkvp
|
||||
=~ (operator):
|
||||
x (field_name).
|
||||
bcd (literal).
|
||||
x=abcd,y=ghi
|
||||
x=abcde,y=ghi
|
||||
|
||||
mlr filter -v $x =~ "^bcd" ./reg_test/input/regex.dkvp
|
||||
=~ (operator):
|
||||
x (field_name).
|
||||
^bcd (literal).
|
||||
|
||||
mlr filter -v $x =~ "^abc" ./reg_test/input/regex.dkvp
|
||||
=~ (operator):
|
||||
x (field_name).
|
||||
^abc (literal).
|
||||
x=abc,y=def
|
||||
x=abcd,y=ghi
|
||||
x=abcde,y=ghi
|
||||
|
||||
mlr filter -v $x =~ "^abc$" ./reg_test/input/regex.dkvp
|
||||
=~ (operator):
|
||||
x (field_name).
|
||||
^abc$ (literal).
|
||||
x=abc,y=def
|
||||
|
||||
mlr filter -v $x =~ "^a.*d$" ./reg_test/input/regex.dkvp
|
||||
=~ (operator):
|
||||
x (field_name).
|
||||
^a.*d$ (literal).
|
||||
x=abcd,y=ghi
|
||||
|
||||
mlr filter -v $x =~ "^a.*"."d$" ./reg_test/input/regex.dkvp
|
||||
=~ (operator):
|
||||
x (field_name).
|
||||
. (operator):
|
||||
^a.* (literal).
|
||||
d$ (literal).
|
||||
x=abcd,y=ghi
|
||||
|
||||
mlr --csvlite put $gmt=sec2gmt($sec) ./reg_test/input/sec2gmt
|
||||
sec,gmt
|
||||
0,1970-01-01T00:00:00Z
|
||||
|
|
|
|||
3
c/reg_test/input/regex.dkvp
Normal file
3
c/reg_test/input/regex.dkvp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
x=abc,y=def
|
||||
x=abcd,y=ghi
|
||||
x=abcde,y=ghi
|
||||
|
|
@ -308,6 +308,13 @@ run_mlr filter -v '$x<$a*-$b+$c' /dev/null
|
|||
run_mlr filter -v '$x<$a+$b*-$c' /dev/null
|
||||
run_mlr filter -v '$x<$a*$b+-$c' /dev/null
|
||||
|
||||
run_mlr filter -v '$x =~ "bcd"' $indir/regex.dkvp
|
||||
run_mlr filter -v '$x =~ "^bcd"' $indir/regex.dkvp
|
||||
run_mlr filter -v '$x =~ "^abc"' $indir/regex.dkvp
|
||||
run_mlr filter -v '$x =~ "^abc$"' $indir/regex.dkvp
|
||||
run_mlr filter -v '$x =~ "^a.*d$"' $indir/regex.dkvp
|
||||
run_mlr filter -v '$x =~ "^a.*"."d$"' $indir/regex.dkvp
|
||||
|
||||
run_mlr --csvlite put '$gmt=sec2gmt($sec)' $indir/sec2gmt
|
||||
run_mlr --csvlite put '$sec=gmt2sec($gmt)' $indir/gmt2sec
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue