[newsgroups line fixed, f'ups set to clpm] Quoth Summercool <[EMAIL PROTECTED]>: > On Jan 25, 5:16 pm, Summercool <[EMAIL PROTECTED]> 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?
This is no good, since 'snoo tire' fails to match even though you want it to. You need something more like / (?: [^s]... | [^n].. | [^o]. | [^w] | ^ ) \s* tire /ix but that gets *really* tedious for long strings, unless you generate it. Ben -- http://mail.python.org/mailman/listinfo/python-list