import re
text = "Hi, Friend!"
print( re.sub(r'Hi', lambda z: z.group() * 30, text) )