On Jan 25, 7:16=A0pm, 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
>
> =A0 tire
>
> but not
>
> =A0 snow tire
>
> or
>
> =A0 snowtire
>

Too bad pyparsing's not an option.  Here's what it would look like:

data =3D """
Match:
>   winter tire
>   tire
>   retire
>   tired

But not match:
>   snow tire
>   snow   tire
>   some snowtires

snowbird tire
tired on a snow day
snow tire and regular tire

"""

from pyparsing import CaselessLiteral,Literal,line

# caseless wasn't really necessary but you never know
# when you'll run into a "Snow tire"
snow =3D CaselessLiteral("snow")
tire =3D Literal("tire")
tire.ignore(snow + tire)

for matchTokens,matchStart,matchEnd in tire.scanString(data):
    print line(matchStart, data)


Prints:

>   winter tire
>   tire
>   retire
>   tired
snowbird tire
tired on a snow day
snow tire and regular tire

-- Paul