1
I’m wearing the sublime and would like to do a mass replace. My texts are in this pattern:
ABC ("Teste regex
I would like to remove the space after the ABC and it should stay that way:
ABC("Teste regex
How the regex would look ?
1
I’m wearing the sublime and would like to do a mass replace. My texts are in this pattern:
ABC ("Teste regex
I would like to remove the space after the ABC and it should stay that way:
ABC("Teste regex
How the regex would look ?
1
It’s quite simple.
In the search use the following regex: (ABC)\s
.
Where it is in parentheses is the content that will remain and the rest outside the group is what will be deleted.
In content to replace, use $1
.
So basically we’re taking everything that was found in the regex "ABC " and replacing it with the contents of the first regex group that is "ABC".
$1 indicates that you are picking up everything found in the first regex group, parentheses define a group.
See working on Regexr
Recalling that the \s
handles spaces, line breaks, tabs, etc. If you want to take only the space, you can put a blank at the end.
0
If your intention is to remove one or more spaces before a parenthesis you can do so:
And finally ( represents the opening of the parentheses, but as this is a special character for the regex we have to add the bar before to escape.
Find: s*(
Replace: (
Browser other questions tagged regex sublime-text
You are not signed in. Login or sign up in order to post.
Can you illustrate ? That part of the $1 I can’t get.
– Roknauta
@Douglas Editei, see if it helps.
– Diego Schmidt
Thank you.... It worked for me like this...:
([A-Z]{3})\s
– Roknauta
@Douglas will also work, but you will get any content with 3 letters followed by a space. I did to pick up exactly ABC. Vlw
– Diego Schmidt
Boy, your explanation was genius.. I was confused with this group story...so they get in parentheses....
– Roknauta