Reputation: 18950
I want to search words as following in "vi":
"AA" not followed by "BB" or "CC"
i.e.
AAXC... -- OK
AABB... -- NOT OK
AACC... -- NOT OK
Not sure how to do that.
Upvotes: 1
Views: 398
Reputation: 41022
vim supports regex searching and substituting http://vimregex.com/:
That is the desired regex:
AA((?!B{2})|(?!C{2}))
The above regex can be validate here.
In vim:
/^\(AA\)\(BB\)\@!.*$
will find all the AA..
format strings and will skip AABB
strings.
in order to skip AACC
and AABB
you can use:
/^\(AA\)\(\(BB\)\|\(CC\)\)\@!.*$
or equivalently:
/^\(AA\)\(\(B\{2\}\)\|\(C\{2\}\)\)\@!.*$
eliminate the ^
from the strings if you want to find strings like
AAXC
inside string of the form BAAXC
.
Upvotes: 3
Reputation: 31203
You can search using regular expressions, just use A[^BC], if it's actually that simple (just characters, not words).
Upvotes: 0