Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!arrayb!wicklund From: wicklund@intellistor.com (Tom Wicklund) Newsgroups: comp.lang.perl Subject: Re: regular expressions Message-ID: <1991Jun5.183443.11524@intellistor.com> Date: 5 Jun 91 18:34:43 GMT References: <1991Jun4.175023.6509@serval.net.wsu.edu> Organization: Intellistor Lines: 15 In <1991Jun4.175023.6509@serval.net.wsu.edu> hakimian@tek4.eecs.wsu.edu (Karl Hakimian - staff) writes: >For example, how would you write a regular expression that accepts a string >with "foo" iff "bar" is not also in the string. Something like (/foo/ && !/bar/) is simplest. A regular expression meeting this would be something like the following. I've tested it and can't find anyplace it doesn't work. If I missed a case, it can be added to the conditions, but it will get messier. Needless to say, the two pattern form above is MUCH more readable. /^([^b]|b+[^ab]|b+a+[^barf]|b+aa+r)*(foo|b+foo|b+a+foo)([^b]|b+[^ab]|b+a+[^bar]|b+aa+r)*$/