import re
p = re.compile("'([^']*(?:''[^']*)*)'")
test_str = "'11','22'',','''33','44''','''55''','6''''6'"
print(p.sub(lambda m: "'{}'".format(m.group(1).replace("''", '&')), test_str))
Regular Expression to Match All Enclosed '' (2 Single Quotes)