Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!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: <1991Jun6.153210.21305@intellistor.com> Date: 6 Jun 91 15:32:10 GMT References: <1991Jun6.053324.19841@uvaarpa.Virginia.EDU> Organization: Intellistor Lines: 14 As I might have expected, the regexp I posted wasn't correct. The following seems closer. /^([^b]|b+[^ab]|b+a+[^barf]|(b|aa+|ab)+r)*(foo|[ba]+foo)([^b]|b+[^ab]|[ba]+[^bar]|(b|aa+|ab)+r)*[ba]*$/ Note that checking for not of a 2 character string has the form (x|y)z, while checking not a 3 character string above has the form (a|b|c|d)e. I imagine longer strings will grow exponentially, so in practice the "/foo/ && !/bar/" form is much more practical. I imagine the regexp definition could be expanded to include a not function (and it might not be too hard to implement from what I remember of looking at the PERL/GNU/Henry Spenser regular expression implementations). It's probably also possible to derive a means of inverting a regular expression, but I wouldn't want to try it.