import re


r = re.compile(r'hello|world')


string = 'hello world the World!!'


x = r.findall(string)
for x in x:
    string = string.replace(x, 'self.' + x)

print(string)
