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

Feature request: loop over a replace command until it doesn't match. #9

Open
RieksJ opened this issue Oct 22, 2020 · 0 comments
Open

Comments

@RieksJ
Copy link

RieksJ commented Oct 22, 2020

@angelo-mollame: Thank you so much for having made this plugin. It is really helpful.

I do have a request. I have files in which I need to replace spaces in quoted phrases with --characters, but not outside the quotes. Currently, this is how I do it:

replace-regex "(\s"[^"\s]*?)\s([^"]*"\s)"
with "$1-$2"
replace-regex "(\s"[^"\s]*?)\s([^"]*"\s)"
with "$1-$2"
replace-regex "(\s"[^"\s]*?)\s([^"]*"\s)"
with "$1-$2"

but this only works for the first three spaces. This cannot be made to work generically.

I would love to see command-looping syntax, e.g. as follows

repeat <n>
replace-regex "(\s"[^"\s]*?)\s([^"]*"\s)"
with "$1-$2"

which would mean that the replace command would be executed times, or until there is no longer a match. The times is to ensure that the loop terminates (and is helpful in other use-cases as well).

Would that be possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant