Just be careful of false positives.
For example, you want to change DOG to CAT in the following:
The dog has been biting the dog’s ass, for eating all the dogfood.
In this case, you only want to change “dog” and not “dog’s” or “dogfood”, so you end up with:
The cat has been biting the dog’s ass, for eating all the dogfood.
The trick here, is to actually change “ dog “ to “ cat “ (see the space before and after?), to rule out any false positives in your string changing.
Just something to be careful of, and something many worthless profanity filters fail to do...
“ass” is profanity, so it becomes a “***”.
Ergo, we see stuff such as “***istance wanted by a high class ******in for Great ***et Quest”