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
I have a file with a few 10000s of strings that match cp[0-9]+ (i.e. "cp" followed immediately by a number with one or more digits)
I want to change these to have the number in square brackets, e.g. I'd like cp36 to become cp[36].
What is the simplest way to do this in Helix?
From what I've found by searching, the "usual" way of selecting with the regex cp[0-9]+ correctly selects all the relevant expressions, but I'm not sure what the correct way of adding brackets is, given that the numbers are of different lengths. (There would be no problem with the "multiple cursor" technique if all the matches were the same length.)
In another editor, this is just a regular expression replacement cp([0-9]+) -> cp\[\0\]
I have a file with a few 10000s of strings that match cp[0-9]+ (i.e. "cp" followed immediately by a number with one or more digits)
I want to change these to have the number in square brackets, e.g. I'd like cp36 to become cp[36].
What is the simplest way to do this in Helix?
From what I've found by searching, the "usual" way of selecting with the regex cp[0-9]+ correctly selects all the relevant expressions, but I'm not sure what the correct way of adding brackets is, given that the numbers are of different lengths. (There would be no problem with the "multiple cursor" technique if all the matches were the same length.)
In another editor, this is just a regular expression replacement cp([0-9]+) -> cp\[\0\]
Right, so you select all cp(\d+), then press s, then select \d+ again. This will select all consecutive digits in your cp-digits selection. Now you can use ms[ to surround each number with a pair of square brackets
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a file with a few 10000s of strings that match
cp[0-9]+
(i.e. "cp" followed immediately by a number with one or more digits)I want to change these to have the number in square brackets, e.g. I'd like
cp36
to becomecp[36]
.What is the simplest way to do this in Helix?
From what I've found by searching, the "usual" way of selecting with the regex
cp[0-9]+
correctly selects all the relevant expressions, but I'm not sure what the correct way of adding brackets is, given that the numbers are of different lengths. (There would be no problem with the "multiple cursor" technique if all the matches were the same length.)In another editor, this is just a regular expression replacement
cp([0-9]+) -> cp\[\0\]
Beta Was this translation helpful? Give feedback.
All reactions