Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing stuff not in an HTML tag

Status
Not open for further replies.

jessica1

Technical User
Aug 1, 2003
3
US
How would I go about replacing a word(s) that's not in an HTML tag? I still want to leave remaining the HTML intact, just replace word(s) that are not in HTML tags. Anybody? Thanks guys.
 
Not sure that I get your question. Could you clarify what you mean by HTML tag? Give an HTML example of what you would want the script to keep versus what you would want the script to remove.
 
Sure, for example if I wanted to replace the words - how, go, still, replace, href, strong - in the following block:
----------
<STRONG>How</STRONG> would I go about replacing a word(s) that's not in an HTML tag? <EM>I still want to leave </EM>remaining the HTML intact, just <a HREF=&quot; word(s)</a> that are not in HTML tags. Anybody? Thanks guys.
----------
This is what would happen to the words(All case insensitive):

How - the first instance would not get replaced because it has the HTML tag <STRONG> around it.

go - the first instance of it would get replaced because there's no surrounding HTML tags around it, and the &quot;go&quot; in &quot;google&quot; would not get replaced because it is part of an html tag.

still wouldn't get replaced because it's around <EM>

replace - would not get replaced because it's around the HREF tag

STRONG - would NOT replace the &quot;STRONG&quot; in the HTML tag

href - would not replace href if it's part of an html tag


This is pretty much what I'm looking for. I've tried a few regular expressions to replace words not in an html tag, but I'm having a hard time. I appreciate any feedback. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top