regular expression negate a word (not character)

regular expression negate a word (not character)

am 26.01.2008 04:30:19 von Summercoolness

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

so for example, it will grep for

winter tire
tire
retire
tired

but will not grep for

snow tire
snow tire
some snowtires

need to do it in one regular expression

Re: regular expression negate a word (not character)

am 26.01.2008 04:59:32 von luiheidsgoeroe

On Sat, 26 Jan 2008 04:30:19 +0100, Summercool > =

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
>
> so for example, it will grep for
>
> winter tire
> tire
> retire
> tired
>
> but will not grep for
>
> snow tire
> snow tire
> some snowtires
>
> need to do it in one regular expression

Untested:

!pregmatch('/(?<=3Dsnow[^\w]*)tire/',$string)
-- =

Rik Wasmus