I'm using the sublime and would like to do a bulk replace. My texts are in this pattern:
ABC ("Teste regex
I would like to remove the space after ABC and should look like this:
ABC("Teste regex
What would be the regex?
I'm using the sublime and would like to do a bulk replace. My texts are in this pattern:
ABC ("Teste regex
I would like to remove the space after ABC and should look like this:
ABC("Teste regex
What would be the regex?
It's pretty simple.
In 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 is going to be deleted.
In the content to replace, use $1
.
So basically we're picking up everything that was found in the "ABC" regex and replacing it with the contents of the first group of the regex that is "ABC".
$ 1 indicates that you are getting everything found in the first group of the regex, the parentheses define a group.
See working at RegExr
Remembering that \s
takes spaces, line breaks, tabs, etc. If you want to take only the space, you can put a space at the end.
If your intention is to remove one or more spaces before a parenthesis you can do this:
Andfinallythe(representstheopeningoftheparentheses,butsincethisisaspecialcharacterforregexwehavetoaddthebarbeforetoescape.
Find:\s*(
Replace:(
Asismispossibletocatchseveraltypesofsituation: