import retext = 'Some text\nwith a {variable\n} value"'print(re.sub(r'{.*?}', lambda m: m.group().replace("\n", ""), text, flags=re.DOTALL))
Standard input is empty
Some text with a {variable} value"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!