I wanted to match an expression which is looking like this:
(<some value with spaces and m$1124any crazy signs> (<more values>) <even more>)
I simply want to split those values along the round brackets (). Currently, I could reduce the pyparsing overhead in the s-expression examplewhich is far to extensive and not understandable (IMHO).
I got as far as to use the nestedExpr statement, which reduces it to one line:
import pyparsing as pp
parser = pp.nestedExpr(opener='(', closer=')')
print parser.parseString(example, parseAll=True).asList()
The result also appears to be split at the white spaces, which I do not want:
skewed_output = [['<some',
'value',
'with',
'spaces',
'and',
'm$1124any',
'crazy',
'signs>',
['<more', 'values>'],
'<even',
'more>']]
expected_output = [['<some value with spaces and m$1124any crazy signs>'
['<more values>'], '<even more>']]
best_output = [['some value with spaces and m$1124any crazy signs'
['more vlaues'], 'even more']]
Optionally, I'd gladly take any points to where I can read some understandable introduction as how to include a more detailed parser (I'd like to extract the value between the < > brackets and match them (see best_output), but I can always string.strip() them afterwards.
Thanks in advance!