import re
print(re.sub("{[^{}]+}", lambda m: m.group()[1:-1], "foo{}bar{baz}"))