str = \'{\"name\": \"John\", \"company\": \"AB\"C corp\", \"id\": \"12g: \"123 12-12\"}\'
B\"C
replace with empty string \'\'
You can try this!
check if you have a character, (a colon or space or both) that is followed by "
and by a \w(character or number).
>>> s
'{"name": "John", "company": "AB"C corp", "id": "12g: "123 12-12"}'
>>> re.sub('\w[: ]*"\w','',s)
'{"name": "John", "company": "A corp", "id": "1223 12-12"}'
Do you mean \W"\W
and \w: "\d
are the only cases you're worrying about?
Then try this:
str = re.sub(r'([a-zA-Z](\: )?"[A-Z0-9])', "", str)