S. Levent Yilmaz wrote:
> Find all lines which contain a given word (say 'kitty') not
> preceded with another given word (say 'puppy') . For instance:
>
> I have two pets:
> my kitty is very cute
> but puppy is cuter than kitty
>
> What regular expression stands only for the 2nd line? Note that the
> other way around is very easy, that is the lines with 'puppy'
> followed by 'kitty' is only "puppy.*kitty"
> Is this possible at all with a single RegExp?
Don't know, but why not just do:
/\bkitty\b/ and !/\bpuppy\b.*\bkitty\b/
--
Gunnar Hjalmarsson
Email:
http://www.gunnar.cc/cgi-bin/contact.pl