I need to parse the line similar to the:
'''Object{identifier='d6e461c5-fd55-42cb-b3e8-40072670fd0f', name='some_name2', identifier='d6e461c5-fd55-42cb-b3e8-40072670fd0f', name='some_name3', value=value_without_quotes}'''
The line is much longer, but the pattern is the same.
Basically, I need a list (or dict) with key, value. Something like:
["'identifier', ''d6e461c5-fd55-42cb-b3e8-40072670fd0f''", "'name', ''some_name2''", "'identifier', ''d6e461c5-fd55-42cb-b3e8-40072670fd0f''", "'name', ''some_name3''", "'value', 'value_without_quotes'"]
I ended up with the following regular expression:
r'Object{(+?)=(+?)}'
It works only if I need the only one object. I'm expecting something like
((+?)=(+?),)+
to be worked, but it's not. For example,
re.match(r'Object{((.+?)=(.+?),?)+}', line3).groups()
Gives me:
("some_name3', value=value_without_quotes", "some_name3', value", 'value_without_quotes')
As you can see 'value=value_without_quotes' appeared. r'Object{(([^=]+?)=(.+?),?)+}' doesn't work also.
So the question is how to repeat the above in sequence? The thing is that I don't if the value contains quotes, symbols or digits.
Thank you
findallinstead ofmatch? You don't need the'Object{at the beginning...