The Monkey wrote:Elaborate, please!

The user will name a URL and a series of text pairs. The PHP will retrieve the html from the URL, substitute the "find" text with the "replace" text, then display the result to the user. You can imagine pulling up a CNN article about "John Kerry" but substituting "Bozo The Clown" for "Kerry". Hilarity ensues!
But, if there's a script in the HTML that uses the word "kerry", or a .js file named "kerry", or any other structural item called "kerry" I want to leave it alone.
I thought this morning that I might do a strpos to find my target string, then do some sort of reverse strpos from that point to find the previous ">" and "<". I could use that to determine if I'm within a tag or not. I'd have to check for <script and <style, too. Any others?
I guess I was hoping somebody would pipe up and say, "Why don't you just use the strReplaceOnlyTextButIgnoreTags function?"
Oh well, it was worth a whack. Thanks for your help.