Skip to content

DSL: How to clear regex capture groups? #1399

Answered by johnkerl
archetyped asked this question in Q&A
Discussion options

You must be logged in to vote

@archetyped I am very sorry for the excessive delay :(

Clearing: you can do "x" =~ "y" (this is non-intuitive and is just a workaround -- see below for more):

$ rlwrap mlr repl
Miller 6.9.0 REPL for darwin/arm64/go1.20.3
Docs: https://miller.readthedocs.io
Type ':h' or ':help' for online help; ':q' or ':quit' to quit.

[mlr] "[\1] [\2]"
"[\1] [\2]"

[mlr] "345 456" =~ "([0-9]+) ([0-9]+)"
true

[mlr] "[\1] [\2]"
"[345] [456]"

[mlr] "x" =~ "y"
false

[mlr] "[\1] [\2]"
"[] []"

Correction: this isn't what you want -- it doesn't recover the "pre" behavior.

Negative matches: I don't see a bug here but I think I misunderstand your ask:

[mlr] "[\1] [\2]"
"[] []"

[mlr] "345 abc" =~ "([0-9]+) ([…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@johnkerl
Comment options

Answer selected by johnkerl
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants