Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Allow for $0 in regex find replace for the whole capture #1127

Open
xbony2 opened this issue May 29, 2020 · 0 comments
Open

Allow for $0 in regex find replace for the whole capture #1127

xbony2 opened this issue May 29, 2020 · 0 comments

Comments

@xbony2
Copy link

xbony2 commented May 29, 2020

Summary

In find replace operations with regex on, $1 in the Replace field refers to the first capture group. In some programming languages/text editors, they will make $0 or the first index (result[0]) of the array returns the entire capture.

Motivation

This is useful when you want to paste the whole thing. Like consider if you have a list of phone numbers, and you use the regex "((\d{3}))(\d{3})-(\d{4})" to try to make it like "Number: ." To do this you kind of have to reconstruct it like "Number: ($1)$2-$3". Under this proposal you just do "Number: $0" which would be easier. This is a trivial example, I used it since I just used it, but you can imagine more complicated ones.

Describe alternatives you've considered

Reconstructing the match, but in some cases, this is inconvenient to do.

Additional context

Current:

image

Potential:

image

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

No branches or pull requests

1 participant