Say I have a string like:
..."StringToMatch":{"id":"StringToMatch","This":"SomeRandomThing"...
Well, it's actually a JSON but I want to treat it like a string for other reasons. How would I find the StringToMatch using regular expressions?
I'm currently using:
value1, value2 = re.findall('"(.*?)":{"id":"(.*?)","This":"SomeRandomThing"', string)[0][:2]
if value1 == value2:
return value1
But it seems a bit of a "hacky" way of doing it. Is there a better way to do it?