mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-25 00:48:56 +00:00
regex-capture iterate
This commit is contained in:
parent
9026df3fad
commit
364951e0e9
3 changed files with 33 additions and 13 deletions
|
|
@ -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
|
||||
|
||||
|
||||
================================================================
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue