-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
What version of ripgrep are you using?
`rg --version
ripgrep 13.0.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)`
How did you install ripgrep?
cargo install
What operating system are you using ripgrep on?
Archlinux 5.17.4-arch1-1
Describe your bug.
When we use the replace flag -r, some characters seem to break the replaced result
if they are placed just after a capture group like $1.
For example underscore (_).
What are the steps to reproduce the behavior?
Run
ls file.mkv | rg '(.*).mkv' -r '$1_en.ass'
Here, _ is just after the 1 in '$1', and it will break the output.
This also happen if we have any alphabet letter after the 1.
What is the actual behavior?
Here are some commands i tried.
ls file.mkv | rg '(.*).mkv' -r '$1_en.ass'
.ass
The $1 is ignored and _ has apparently eaten the "en" part of the pattern.
ls file.mkv | rg '(.*).mkv' -r '$1$_en.ass'
file.ass
Since $$ is used to escape $, i tried to write $_,
and while it still eats the "en" part, the $1 is correctly replaced this time.
ls file.mkv | rg '(.*).mkv' -r '$1 en.ass'
file en.ass
Here we can see that the output is correct if a space follow the 1, this is also the case for ., !, and probably others.
What is the expected behavior?
The expected behavior to the first command listed above is :
file_en.ass
I think this is a bug, but if this is intentional, then please show me where in the doc i could have find this, because i have not.
Is there a way to escape the capture group and/or find a way for underscore to not break the output ?