I have strings that contain a number somewhere in them and I\'m trying to replace this number with their word notation (ie. 3 -> three). I have a function that does this. Th
To make your function fit with re.sub, you can wrap it with a lambda:
re.sub
re.sub('pattern', lambda m: myfunction(m.group()), 'text')