You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
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:
Potential:
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
Potential:
The text was updated successfully, but these errors were encountered: