Search and Replace using regex in python

前端 未结 2 1456
感动是毒
感动是毒 2021-01-26 10:52
str = \'{\"name\": \"John\", \"company\": \"AB\"C corp\", \"id\": \"12g: \"123 12-12\"}\'

B\"C replace with empty string \'\'

2条回答
  •  后悔当初
    2021-01-26 11:51

    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)
    

提交回复
热议问题