Reputation: 9506
I have a file with a few thousand lines, and in this file I have some regex expressions...
The regex expressions are all over the place, and recently we've changed the expression and I need to update all of them.
I need to change all instances of: [A-z -']+
with [A-z \-']+
so I tried doing :%s/[A-z -']+/[A-z \-']+/g
but that replaced all occurrences of [A-z -']+
with [A-z -'[A-z -']+
Is there some other way to do this?
Upvotes: 1
Views: 79
Reputation: 786291
You may use this substitution:
%s/\[A-z -']/[a-zA-Z '-]/g
It is wrong to use [A-z]
as it will match many more characters than just [A-Za-z]
and it is better to move hyphen to end position before closing ]
to get the regex right.
Upvotes: 3