Skip to content

Variables in --replace string, e.g., ${filename}, ${linenum}, etc #2253

Answered by BurntSushi
condekind asked this question in Q&A
Discussion options

You must be logged in to vote

No, there aren't. The documentation is correct. And I don't have any plans to add any. ripgrep is a search tool. I do not want to turn it into replacement tool or a sed-like replacement. The FAQ lists other tools for that.

Also, do note that the variables currently available are not really "PCRE2 variables." They are capture group variables. The replacement code is implemented as generic interpolation that works for any regex engine. See: https://docs.rs/grep-matcher/latest/grep_matcher/trait.Captures.html#method.interpolate

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
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