I have a naive \"parser\" that simply does something like:
[x.split(\'=\') for x in mystring.split(\',\')]
However mystring can be something like<
Assuming that the name of the key never contains ,
, you can split at ,
when the next sequence without ,
and =
is succeeded by =
.
re.split(r',(?=[^,=]+=)', inputString)
(This is the same as my original solution. I expect re.split
to be used, rather than re.findall
or str.split
).
The full solution can be done in one-liner:
[re.findall('(.*?)=(.*)', token)[0] for token in re.split(r',(?=[^,=]+=)', inputString)]