Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Perl-Users Digest #651 Message-ID: <1991Mar11.224901.26872@jpl-devvax.jpl.nasa.gov> Date: 11 Mar 91 22:49:01 GMT References: <1991Mar9.230553.22037@uvaarpa.Virginia.EDU> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 29 In article <1991Mar9.230553.22037@uvaarpa.Virginia.EDU> Marc Horowitz writes: : |> From: tchrist@convex.COM (Tom Christiansen) : |> : |> From the keyboard of emv@ox.com (Ed Vielmetti): : |> :Speaking of which, what's the limits on the number of parentheses that : |> :a regular expression can have? I got an unpleasant message : |> : : |> :/^(scan)\s+((-(\w*))|)\s*\+(\w*)((s+((||>)(.*)))|)/: too many () in regexp at /u:1/emv/bin/smoke line 167, <> line 1. : |> : |> Nine. To accept more, Larry would have to change the code that : |> recognizes \1 .. \9 and $1 .. .$9. : |> : |> --tom : : Ok, that explains it, but it doesn't excuse it. Sometimes I want to : match an expression complex enough (like Ed's example) that I need : more than nine () to group everything. In this case, perl should : still work, and I would say that the regexp in an array context should : contain as many elements as paren pairs, but that $1 .. $9 should : contain the first nine () matches. There's actually no syntactic reason we can't have $10 and higher, but \10 already means a backspace. Implementation-wise, Henry's regexp package has a hardwired limit of 9, and fixing that will entail changing the way the pattern-matching opcodes are set up, and this is non-trivial, I think. I kludged around this when adding {n,m}, and maybe I'll just kludge it again. Sigh. I agree that the limit shouldn't be there. Larry