Damned cut-and-paste in GoogleGroups edit window (leading '.'s are to
retain spacing):
.# get pyparsing at http://pyparsing.sourceforge.net
.
.from pyparsing import quotedString, printables, Word, OneOrMore,
Forward, Literal,delimitedList,Group
.
.line1 = """path {{data/tom} C:/user/john}"""
.line
Gee, no takers?
Here's a (surprise!) pyparsing solution.
-- Paul
.# get pyparsing at http://pyparsing.sourceforge.net
.
.from pyparsing import quotedString, printables, Word, OneOrMore,
Forward, Literal,delimitedList,Group
.quotedString.setParseAction(lambda s,l,t: t[0].strip("'\""))
.
.line1 =
Hi all,
I want to parse some string lines into name value pairs, where the value
will be a list. Here are some sample lines:
line1 = """path {{data/tom} C:/user/john}"""
line2 = """books{{book music red} {book {math 1}
blue} {book {tom's book} green}}"""
For line1, the name is "path", the name-v