import retext = "a,b,{'c','d','e','f'},g,h"print(re.sub(r"{[^{}]+}", lambda x: x.group(0).replace(",", ";"), text))
Standard input is empty
a,b,{'c';'d';'e';'f'},g,h
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!