On 5/2/06, o1792 <[EMAIL PROTECTED]> wrote:
Hi vimmers,

When searching through text files using regex, I am
trying
unsuccessfully to negated a complicated pattern
without success.

What doesn't help is the double usage of the
circumflex ^ character
(may also be called caret, not sure), because it also
means start of a
line.

However when used within square brackets, it negates
the character in
front of it. i.e. [^p] finds anything that is not p.
[^aeiou] finds
anything that is not a lower case vowel. That's all
well and good but when
you have a sequence (usually grouped) you're trying to
negate, simple
obvious approaches have not worked.

 if you want to find anything that is not any word
ending in "ion",
well the regex group you're looking at is
\(\<.\+ion\>\), but how do you
negate that? Put it all in square brackets and provide
a caret ^ at the
beginning? Nope. in fact group within square brackets
doesn't work as
might be expected. Th enegation pretty much seems to
be built for single
character negation only, not sequences.

I'm only referrign to searching here, when it comes to
substituting or
deleting, :v/etc/d seems tailor nmade to help with
negations of tricky
regex.

Pattern
  /\i\+\(ion\)\@<!\>/
matches words that do not end with 'ion'

BTW, can anyone explain why this pattern does *not*
work, does not match words that do not end with 'ion' :
   /\i\+\(ion\)[EMAIL PROTECTED]/
I thought this pattern would match words not ending with
'ion'. But it matches all words, including words ending
with 'ion'. Why ?

Yakov

Reply via email to