Newsgroups: comp.lang.perl
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!convex!usenet
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: regular expressions
Message-ID: <1991Jun04.230710.18922@convex.com>
Sender: usenet@convex.com (news access account)
Nntp-Posting-Host: pixel.convex.com
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Software Development, Richardson, TX
References: <1991Jun4.175023.6509@serval.net.wsu.edu>
Date: Tue, 04 Jun 1991 23:07:10 GMT
Lines: 16

From the keyboard of hakimian@tek4.eecs.wsu.edu (Karl Hakimian - staff):
:For example, how would you write a regular expression that accepts a string
:with "foo" iff "bar" is not also in the string.

I'd probably write it as two pattern-matches, one negated:

    if (!/bar/ && /foo/) {

or 

    $ok = /foo/ && !/bar/;

--tom
--
Tom Christiansen		tchrist@convex.com	convex!tchrist
	    "Perl is to sed as C is to assembly language."  -me
