What would be the best way in Python to parse out chunks of text contained in matching brackets?
\"{ { a } { b } { { { c } } } }\"
should i
Cleaner solution. This will find return the string enclosed in the outermost bracket. If None is returned, there was no match.
def findBrackets( aString ):
if '{' in aString:
match = aString.split('{',1)[1]
open = 1
for index in xrange(len(match)):
if match[index] in '{}':
open = (open + 1) if match[index] == '{' else (open - 1)
if not open:
return match[:index]