I have a string such as this one:
a=func(1, 2, 2), b='hey', c=foobar('text'), d=1
which I'd like to parse into its key-value components, so that I can obtain a list of
[['a', 'func(1, 2, 2)', ['b', '\'hey\''], ['c', 'foobar(\'text\')'], ['d', '1']]
My approach was to use this regex: (\w*) *= *([^=]*), (?=\w* *=)
with a positive lookahead, but that's ignoring the last key-value pair (d=1
). Any idea how I can make the positive lookahead optional?