regular expression negate a word (not character)

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
Summercoolness [ Sa, 26 Januar 2008 04:30 ] [ ID #1916921 ]

Re: regular expression negate a word (not character)

On Sat, 26 Jan 2008 04:30:19 +0100, Summercool <Summercoolness [at] 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
>
> 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
luiheidsgoeroe [ Sa, 26 Januar 2008 04:59 ] [ ID #1916922 ]
PHP » comp.lang.php » regular expression negate a word (not character)

Vorheriges Thema: New PHP MVC Framework - QPHP.NET
Nächstes Thema: Files in folder