Yes, I can believe that. don't think regex is the most efficient thing in the world. Some of the tests I did resulted in LC running out of memory too! That's another thing I think should work better with matchText and matchChunk. Any errors, eg a bad regex, result in a runtime error - would be much better if they put something into the result.
Pete lcSQL Software <http://www.lcsql.com> On Sun, Jul 28, 2013 at 12:54 AM, Geoff Canyon <gcan...@gmail.com> wrote: > I checked, and your solution and my strictTotalMatching function return > identical results. It took me a while to figure out how it works. It's very > clever, but interestingly, not very efficient -- it almost certainly > doesn't matter for the likely use cases, but if you throw a string with a > few thousand (s and )s at it, seconds will go by before you get the result. > > gc > > > On Fri, Jul 26, 2013 at 12:02 PM, <dunb...@aol.com> wrote: > > > I am old fashioned. And late. I think this works: > > > > > > > > on mouseUp > > answer findNests(fld 1) > > end mouseUp > > > > > > function findNests var > > repeat with y = 1 to the number of chars in var > > if char y of var = "(" then put y & return after lefts --build list > > of left paren > > if char y of var = ")" then put y & return after rights --build > list > > of right paren > > end repeat > > put 0 & return before rights > > > > repeat with y = the number of lines of lefts down to 1 > > repeat with u = the number of lines of rights down to 1 > > if line y of lefts < line u of rights and line y of lefts > line > > u-1 of rights then > > put line y of lefts & "," & line u of rights & return after > > accum > > delete line y of lefts > > if line u of rights <> 0 then delete line u of rights > > end if > > end repeat > > end repeat > > sort accum numeric > > return accum > > end findNests > > > > > > The returned list orders the char numbers of the paired parens. > > > > > > Craig > > > > > > > > -----Original Message----- > > From: Peter Haworth <p...@lcsql.com> > > To: How to use LiveCode <use-livecode@lists.runrev.com> > > Sent: Fri, Jul 26, 2013 12:09 pm > > Subject: Re: Finding matched parentheses > > > > > > On Fri, Jul 26, 2013 at 12:10 AM, Thierry Douez <th.do...@gmail.com> > > wrote: > > > > > But this one will work and match the first occurence: > > > > > > if matchChunk(mystring,"(\([^)]*\)).*",tstart,tEnd) > > > > > > Regards, > > > > > > Thierry > > > > > > > Nice Thierry! Doesn't handle nested parens though, but once again, that > > may not be a possibility in the OP's scenario. > > > > Pete > > lcSQL Software <http://www.lcsql.com> > > _______________________________________________ > > use-livecode mailing list > > use-livecode@lists.runrev.com > > Please visit this url to subscribe, unsubscribe and manage your > > subscription > > preferences: > > http://lists.runrev.com/mailman/listinfo/use-livecode > > > > > > _______________________________________________ > > use-livecode mailing list > > use-livecode@lists.runrev.com > > Please visit this url to subscribe, unsubscribe and manage your > > subscription preferences: > > http://lists.runrev.com/mailman/listinfo/use-livecode > > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode