import re
pattern = "world! {} "
text = "hello world! this is python"
def find_variable(pattern, text):
return re.findall(pattern.format(r'(\S+)'), text)[0]
print (find_variable(pattern, text))
aW1wb3J0IHJlCgpwYXR0ZXJuID0gIndvcmxkISB7fSAiCnRleHQgPSAiaGVsbG8gd29ybGQhIHRoaXMgaXMgcHl0aG9uIgoKZGVmIGZpbmRfdmFyaWFibGUocGF0dGVybiwgdGV4dCk6CglyZXR1cm4gcmUuZmluZGFsbChwYXR0ZXJuLmZvcm1hdChyJyhcUyspJyksIHRleHQpWzBdCgpwcmludCAoZmluZF92YXJpYWJsZShwYXR0ZXJuLCB0ZXh0KSk=