Hi, I have a little problem.
I want to replace words in a text, but only 'whole words'. That is, I'm looking for a method that changes "cat", but not "catfood".
I know how to do it using re.sub, like this:
re.sub(r'\bword\b', 'change', text)
Only problem is, I'm using a dictionary in an external textfile for this, and while that works fine if I do it straightforward, I haven't found a way to take 'whole words' into account while using the dictionary.
Is this possible? If so, I would really appreciate advice.