import re
translation = {
r'\{fuck\}': '{1}',
'you': '{2}'
}
text ='{fuck} you'
pattern = re.compile(r'\b(' + '|'.join(translation.keys()) + r')\b')
print(r'\b(' + '|'.join(translation.keys()) + r')\b')
print(pattern.sub(lambda x: translation[x.group()], text))
CmltcG9ydCByZQoKCnRyYW5zbGF0aW9uID0gewogICAgcidce2Z1Y2tcfSc6ICd7MX0nLAogICAgJ3lvdSc6ICd7Mn0nCn0KCnRleHQgPSd7ZnVja30geW91JwpwYXR0ZXJuID0gcmUuY29tcGlsZShyJ1xiKCcgKyAnfCcuam9pbih0cmFuc2xhdGlvbi5rZXlzKCkpICsgcicpXGInKQpwcmludChyJ1xiKCcgKyAnfCcuam9pbih0cmFuc2xhdGlvbi5rZXlzKCkpICsgcicpXGInKQpwcmludChwYXR0ZXJuLnN1YihsYW1iZGEgeDogdHJhbnNsYXRpb25beC5ncm91cCgpXSwgdGV4dCkpCg==