Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!sdd.hp.com!ucsd!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: Matching parentheses Message-ID: <1990Nov28.200509.23925@iwarp.intel.com> Date: 28 Nov 90 20:05:09 GMT References: <1990Nov28.150131.28981@ugle.unit.no> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 16 In-Reply-To: harald.alvestrand@elab-runit.sintef.no In article <1990Nov28.150131.28981@ugle.unit.no>, harald.alvestrand@elab-runit writes: | I have thought a long time about this, but I am sure there must be some | magic way to do it: | How can I write a pattern that matches (), ((())), ((())()), but NOT ((())? | That is, how do I get a balanced matching of parentheses? | (or quotes, for that matter...) Regular expressions aren't strong enough. You need to use some other method (like recursive descent). Just another Perl hacker (also in the midst of hacking the final Book draft), -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/