Reputation: 579
I try to come up a regular expression to capture the following pattern:
I want to include the characters from a-z, but exclude e, f and g I know the characters class in Vim
[^efg]
excludes characters: e, f and g
I have tried follwoing regular expression
%s/[a-z[^efg]]//gc
but it doesn't capture what I want
Upvotes: 1
Views: 75
Reputation: 378
Another way to do that:
:%s/[efg]\@!.//g
Because \@!
do negative/inverse match.
Upvotes: 0
Reputation: 76547
You could consider using the other ranges that you need (i.e. [a-d]
and [h-z]
) within a single character group, which should match every character except those you explicitly excluded:
[a-dh-z]
Example
You can see an interactive example of this here.
Upvotes: 5