Finding matched parentheses

dunbarx at aol.com dunbarx at aol.com
Mon Jul 29 16:15:24 EDT 2013


Hmmm.


I read the original post as finding the "closing parenthesis ... of a pair"


"Any pair?" 


This seems to indicate that all nested parens have to be parsed as a whole. If you want to find a particular
related couple, you have to use the correct ordered pair derived from the function.


It is much simpler to find the first ")" and work backward. But that would preclude nested parens, since the 
firstmost and innermost pair would be the only one found. You cannot find that kind of first "pair" and also
include nested pairs. That first pair is always minimally small.


The function could be easily modified to list all pairs within any designated pair, of course.



Anyway, it was fun to play with.


Craig


-----Original Message-----
From: Peter Haworth <pete at lcsql.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Mon, Jul 29, 2013 1:15 pm
Subject: Re: Finding matched parentheses


On Mon, Jul 29, 2013 at 9:07 AM, <dunbarx at aol.com> wrote:

> I tired your script on the string:
>
>
>
> aa(ss)(xx)(yy)
>
>
>
> it only returned the parens bracketing "ss"
>

I Think that's what he wants to do - just find the position of the first
set of parentheses, taking nested parens into account.  But not sure.....

Personally, I'd use the regex that Thierry posted a couple of days back.
 No recursion involved and one line of code does the job.

Pete
lcSQL Software <http://www.lcsql.com>
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list