I have a string in Python, say The quick @red fox jumps over the @lame brown dog.
I\'m trying to replace each of the words that begin with @
Try:
import re
match = re.compile(r"@\w+")
items = re.findall(match, string)
for item in items:
string = string.replace(item, my_replace(item)
This will allow you to replace anything that starts with @ with whatever the output of your function is. I wasn't very clear if you need help with the function as well. Let me know if that's the case