vars = {'search': 'replace', 'foo': 'bar'}
mystring = 'Foo bar %foo% % search %.'
for k, v in list(vars.items()):
    mystring = mystring.replace('%%%s%%' % k, v)
print(mystring)
Regex to replace %variables%