Hi,
While the above two solutions are great, and will provide a nice clean approach to replacing the tags later, it is not quite what I need. Sorry, my explaining skills are lacking! :rolleyes:
OK, I'll rephrase my original problem...
Forget about the tags included in my text for a sec. I have a database of keywords with which I want to check against each word in the page being shown and highlight (much like the google highlighing when you search for a term).
Now obviously this is as simple as a str_replace(). My problem now is that I don't want to replace matching words if they are in between tags. My [h] [/h] set of tags I used as an example above representings a heading. I don't want a matched word in a heading to be highlighted.
Likewise, the tag [image=xxx.jpg]test[/image] represents an image with the text between being the alt-text.
Now, the 'page' is available to me in a string. Replacing all the tags and such isn't a problem, it's just I want to highlight the words first.
What I think I need to do is only replace a word if, and only if, it is between a [/x] tag and a [x] tag. I think this satisifies my problem, but I am having problems actually implementing this (as can be seen from my dismal approach at a regular expression above! :p ).
So, any pointers welcome... thanks again!
Regards,
Russ