Finding matched parentheses

dfepstein at comcast.net dfepstein at comcast.net
Mon Jul 29 21:57:32 EDT 2013


Testing for speed, I found that my July 29 function--the one that uses lineDelimiter and itemDelimiter--is thwarted when two parens appear as consecutive characters, and gives the wrong answer in that case. Sorry about that. 


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". 


function offsetPair6 str 
put "\((((?>[^()]+)|(?R))*)\)" into tRegex 
get matchChunk(str,tRegex,tStart,tEnd) 
return tStart && tEnd 
end offsetPair6 


As far as I know the function I posted July 26 works correctly. 


David Epstein 


More information about the use-livecode mailing list