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 <[email protected]>
To: How to use LiveCode <[email protected]>
Sent: Mon, Jul 29, 2013 1:15 pm
Subject: Re: Finding matched parentheses


On Mon, Jul 29, 2013 at 9:07 AM, <[email protected]> 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
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to