On Tue, May 02, 2006 at 02:03:47PM -0400, James Vega wrote:
> On Tue, May 02, 2006 at 08:27:49PM +0300, Yakov Lerner wrote:
> > On 5/2/06, o1792 <[EMAIL PROTECTED]> wrote:
> > 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 ?
> 
> That pattern will match as long as you don't force it to leave 3
> characters after the negation.  Given the word description:
> 
>    descript.ion <-- won't match because \(ion\)[EMAIL PROTECTED] matches AT 
> that point
>    description. <-- works just fine because there's no 'ion' at the
>                     current position
> 
>    /\i\+\(ion\)[EMAIL PROTECTED]>
> 
> The above pattern will do what you wanted since it forces there to be 3
> more characters and the end of word when you try to match 'ion'.

That won't match words of fewer than four characters.  To match all
words that don't end in "ion" it's better to do:

     /\<\(\i*\(ion\)[EMAIL PROTECTED]|\i\i\=\)\>
      ^^^^  ^                ^^^^^^^^^^

(The leading \< is required to prevent the pattern matching the "on" at
the end of words like "negation".  The alternate part at the end catches
all words of one or two letters.)

-- 
Matthew Winn ([EMAIL PROTECTED])

Reply via email to