Finding matched parentheses

Peter Haworth pete at lcsql.com
Tue Jul 30 01:17:33 EDT 2013


On Mon, Jul 29, 2013 at 6:57 PM, <dfepstein at comcast.net> wrote:

> I may not have correctly implemented Peter Haworth's Regex string, but I
> get wrong answers from writing the function as below --
> offsetPair6("(a(a))") returns "2 5".


Hi David,
The regex actually returns the string within the parens so to get the char
position of the parens, the function should return tStart-1 and tEnd+1
which would be 1 and 6 in your example, which I think is what you want?

Glad your function works though, you should probably go with it if it feels
more comfortable.  Your situation was a challenge for me to find a way to
do it with a regex :-)

Pete
lcSQL Software <http://www.lcsql.com>



More information about the use-livecode mailing list