Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacements - $1 not recognized if followed by underscore #2455

Closed
brunetton opened this issue Mar 15, 2023 · 2 comments
Closed

replacements - $1 not recognized if followed by underscore #2455

brunetton opened this issue Mar 15, 2023 · 2 comments
Labels
duplicate An issue that is duplicative of another.

Comments

@brunetton
Copy link

What version of ripgrep are you using?

ripgrep 13.0.0

How did you install ripgrep?

Debian

What operating system are you using ripgrep on?

Ubuntu 22.04

Describe your bug.

Can't use $1 in replacements when followed by underscore

What are the steps to reproduce the behavior?

echo "hello" | rg '(.*)' -r '--$1_--'

What is the actual behavior?

DEBUG|rg::config|crates/core/config.rs:40: /home/bruno/.ripgreprc: arguments loaded from config file: ["--no-line-number"]
DEBUG|rg::args|crates/core/args.rs:543: final argv: ["rg", "--no-line-number", "(.*)", "-r", "--$1_--", "--debug"]
DEBUG|globset|/usr/share/cargo/registry/ripgrep-13.0.0/debian/cargo_registry/globset-0.4.8/src/lib.rs:421: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
----

What is the expected behavior?

Output should be: --hello_--

@BurntSushi
Copy link
Owner

Duplicate of #2201.

Use ${1} instead. Otherwise the _ is treated as part of the capture group reference.

@BurntSushi BurntSushi closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
@BurntSushi BurntSushi added the duplicate An issue that is duplicative of another. label Mar 15, 2023
@brunetton
Copy link
Author

Sorry for the duplicate !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate An issue that is duplicative of another.
Projects
None yet
Development

No branches or pull requests

2 participants