Replace words in string
Posted on 2009-04-01
I have documents, and there are certain words in those documents that I want to replace with a new word.
for example, I want to replace all instances of
dog with cat.
I know I can do a str_replace and this will do it for me, however I run into an issue where it would replace "hotdog" with "hotcat", which is something I do not want to do. So str_replace is not an option.
Some of the words, also have an apostrophe in them, so I would like to take those into account as well.