Somewhere around here, I have an over-engineered super-Steve Replace function. Life's just been hectic as all get out here recently, and between everything in general, and swapping files and such from the old PC to the new one, I don't have a clue where it's at currently.
The way my extreme version works is more or less:
SUB Replace (text$, delimiter$, prefix$, search$, postfix$, replace$)
The idea is:
1) You give it a text string. "Cats eat cat-food, not cat food. That would be acatastrophy!"
2) You choose a given delimiter. "*"
3) You choose a search string, making use of the delimiter$. "cat*"
4) You can choose a prefix or postfix to modify your work. postfix$ = "-"
5) You give it a replacement string. "dog"
The routine then searches your text$ for search$ (minus any delimiters, which would be "cat", from above).
The first "Cats" gets changed to "Dogs". That "*" in "cat*" in the search string says we ignore any character after the "cat".
The "cat-food" doesn't change, as we have a postfix saying keep "cat" if a "-" occurs after it.
The next "cat" changes.
The final "acatastrophy" doesn't change. There's no open delimiter before the "cat" in our search string, like the "*" is after it, so that leading "a" prevents it from being altered.
The final result would be "Dogs eat cat-food, not dog food. That would be acatastrophy!"
Now, if I can just sort out where the heck that routine actually went to in all this mess, I'll share it sometime....