fork download
  1. import re
  2. p = re.compile(r"'([^']*(?:''[^']*)*)'")
  3. test_str = "'11','22'',','''33','44''','''55''','6''''6'"
  4. print(p.sub(lambda m: "'{}'".format(m.group(1).replace("''", "&")), test_str))
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
'11','22&,','&33','44&','&55&','6&&6'