On Jan 25, 2008 6:19 PM, Summercool <Summercoolness / gmail.com> wrote:
> On Jan 25, 5:16 pm, Summercool <Summercooln... / gmail.com> wrote:
> > somebody who is a regular expression guru... how do you negate a word
> > and grep for all words that is
> >
> >   tire
> >
> > but not
> >
> >   snow tire
> >
> > or
> >
> >   snowtire
>
> i could think of something like
>
>   /[^s][^n][^o][^w]\s*tire/i
>
> but what if it is not snow but some 20 character-word, then do we need
> to do it 20 times to negate it?  any shorter way?

(?!snow)(\S{4})\s*(tire)|^\S{0,3}\s*(tire)

I'm not thrilled with that, but without look-behind, it's rough to do
what you're asking.

Shameless pluggery: I used RegexpBench to do the experimentation to
find your answer.

Judson
-- 
Your subnet is currently 169.254.0.0/16.  You are likely to be eaten by a grue.