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

specify and implement behavior for combining --only-matching with --replace #443

Closed
BurntSushi opened this issue Apr 10, 2017 · 2 comments
Closed
Labels
question An issue that is lacking clarity on one or more points.

Comments

@BurntSushi
Copy link
Owner

@kpp writes:

How about:

$ rg '(?P<first>[A-Z][a-z]+)\s+(?P<last>[A-Z][a-z]+)'  tests/test.txt -o
7:Baker Street
$ rg '(?P<first>[A-Z][a-z]+)\s+(?P<last>[A-Z][a-z]+)'  tests/test.txt -o --replace '$last, $first'
7:Street, Baker

@mernen writes:

Guess someone beat me to implementing -o! (Which is fair, I’ve been postponing this since January)

So, as I mentioned in #308, I think the best combination for --only-matching and --replace would be an approximation of Ack’s --output: perform a replace on the matched part, and output only the result of the replacement, not anything else on the line. If there are multiple matches on a single line, output multiple lines. Same as on @kpp’s last comment, if I understood it correctly.


See also #422

@BurntSushi BurntSushi added the question An issue that is lacking clarity on one or more points. label Apr 10, 2017
@BurntSushi
Copy link
Owner Author

Note that this still needs a specification. Ideally, the specification is in the form of user facing documentation.

@BurntSushi
Copy link
Owner Author

This was done in #593.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question An issue that is lacking clarity on one or more points.
Projects
None yet
Development

No branches or pull requests

1 participant