From 364951e0e905b73e464fb22324ef7ebd65d36649 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 17 Jan 2016 23:14:02 -0500 Subject: [PATCH] regex-capture iterate --- c/reg_test/expected/out | 32 ++++++++++++++++++++++++++------ c/reg_test/run | 12 ++++++------ c/todo.txt | 2 +- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/c/reg_test/expected/out b/c/reg_test/expected/out index 1421fafab..798fab237 100644 --- a/c/reg_test/expected/out +++ b/c/reg_test/expected/out @@ -9625,10 +9625,11 @@ x=abcd,y=ghi ================================================================ DSL REGEX CAPTURES -mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)"; $F1 = "\1"; $F2 = "\2" ./reg_test/input/capture.dkvp +mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)"; $F1="\1"; $F2="\2" ; $F3="\3" ./reg_test/input/capture.dkvp FIELD ABC123 F1 ABC F2 123 +F3 FIELD ABC..123 @@ -9636,88 +9637,107 @@ FIELD ..ABC..123.. FIELD none of the above -mlr --oxtab put $FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"; $F1 = "\1"; $F2 = "\2" ./reg_test/input/capture.dkvp +mlr --oxtab put $FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"; $F1="\1"; $F2="\2" ; $F3="\3" ./reg_test/input/capture.dkvp FIELD ABC123 F1 ABC F2 123 +F3 FIELD ABC..123 F1 ABC F2 123 +F3 FIELD ..ABC..123.. F1 ABC F2 123 +F3 FIELD none of the above -mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)" || 1==1; $F1 = "\1"; $F2 = "\2" ./reg_test/input/capture.dkvp +mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)" || 1==1; $F1="\1"; $F2="\2" ; $F3="\3" ./reg_test/input/capture.dkvp FIELD ABC123 F1 ABC F2 123 +F3 FIELD ABC..123 F1 \1 F2 \2 +F3 \3 FIELD ..ABC..123.. F1 \1 F2 \2 +F3 \3 FIELD none of the above F1 \1 F2 \2 +F3 \3 -mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)" then put $F1 = "\1"; $F2 = "\2" ./reg_test/input/capture.dkvp +mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)" then put $F1="\1"; $F2="\2" ; $F3="\3" ./reg_test/input/capture.dkvp FIELD ABC123 F1 \1 F2 \2 +F3 \3 FIELD ABC..123 F1 \1 F2 \2 +F3 \3 FIELD ..ABC..123.. F1 \1 F2 \2 +F3 \3 FIELD none of the above F1 \1 F2 \2 +F3 \3 -mlr --oxtab put $FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)" then put $F1 = "\1"; $F2 = "\2" ./reg_test/input/capture.dkvp +mlr --oxtab put $FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)" then put $F1="\1"; $F2="\2" ; $F3="\3" ./reg_test/input/capture.dkvp FIELD ABC123 F1 \1 F2 \2 +F3 \3 FIELD ABC..123 F1 \1 F2 \2 +F3 \3 FIELD ..ABC..123.. F1 \1 F2 \2 +F3 \3 FIELD none of the above F1 \1 F2 \2 +F3 \3 -mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)" || 1==1 then put $F1 = "\1"; $F2 = "\2" ./reg_test/input/capture.dkvp +mlr --oxtab put $FIELD =~ "([A-Z]+)([0-9]+)" || 1==1 then put $F1="\1"; $F2="\2" ; $F3="\3" ./reg_test/input/capture.dkvp FIELD ABC123 F1 \1 F2 \2 +F3 \3 FIELD ABC..123 F1 \1 F2 \2 +F3 \3 FIELD ..ABC..123.. F1 \1 F2 \2 +F3 \3 FIELD none of the above F1 \1 F2 \2 +F3 \3 ================================================================ diff --git a/c/reg_test/run b/c/reg_test/run index ee9ec5a26..a45e86fc8 100755 --- a/c/reg_test/run +++ b/c/reg_test/run @@ -935,13 +935,13 @@ run_mlr filter -v '$x =~ "^a.*"."d$"i' $indir/regex.dkvp # ---------------------------------------------------------------- announce DSL REGEX CAPTURES -run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)"; $F1 = "\1"; $F2 = "\2"' $indir/capture.dkvp -run_mlr --oxtab put '$FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"; $F1 = "\1"; $F2 = "\2"' $indir/capture.dkvp -run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)" || 1==1; $F1 = "\1"; $F2 = "\2"' $indir/capture.dkvp +run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)"; $F1="\1"; $F2="\2" ; $F3="\3"' $indir/capture.dkvp +run_mlr --oxtab put '$FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"; $F1="\1"; $F2="\2" ; $F3="\3"' $indir/capture.dkvp +run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)" || 1==1; $F1="\1"; $F2="\2" ; $F3="\3"' $indir/capture.dkvp -run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)"' then put '$F1 = "\1"; $F2 = "\2"' $indir/capture.dkvp -run_mlr --oxtab put '$FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"' then put '$F1 = "\1"; $F2 = "\2"' $indir/capture.dkvp -run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)" || 1==1' then put '$F1 = "\1"; $F2 = "\2"' $indir/capture.dkvp +run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)"' then put '$F1="\1"; $F2="\2" ; $F3="\3"' $indir/capture.dkvp +run_mlr --oxtab put '$FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"' then put '$F1="\1"; $F2="\2" ; $F3="\3"' $indir/capture.dkvp +run_mlr --oxtab put '$FIELD =~ "([A-Z]+)([0-9]+)" || 1==1' then put '$F1="\1"; $F2="\2" ; $F3="\3"' $indir/capture.dkvp # ---------------------------------------------------------------- announce DSL DATETIME FUNCTIONS diff --git a/c/todo.txt b/c/todo.txt index b5f56db33..d08bccc54 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -28,7 +28,7 @@ TOP OF LIST > mlr put '$y = sub($x, "([hg])e.*l(.)", "y\1y123\2y")' > so sub/gsub backcaptures are in-function only; =~/!=~ are out-of-function - on-line help & mld - - UT. incl. up to \9. + - UT. incl. up to \9. question current UTs. - boolean true/false literals into the DSL? ! need a performant way to distinguish tried-but-no-match vs. no-match-tried for expanding \1 etc., if impl'd