ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 20th, 2005, 09:13 PM
premzero premzero is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Sydney, AU
Posts: 36 premzero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 58 sec
Reputation Power: 5
Regular expression: going mad!

I've given up. Been a long day.. how do you escape this tag in a string?

Code:
<SCRIPT language=JavaScript>
 function convertCMAXSpaceto20(urlx)   {                                          var strUrlNew;                        strUrlNew = '';                       for (i=0; i < urlx.length; i++)       {                                  	    switch (urlx.charAt(i))        	    {                            			case '+' :                   				strUrlNew += '%2B';      				break;                   			case ',' :                   				strUrlNew += '%2C';      				break;                   			case '"/' :                  				strUrlNew += '%2F';      				break;                   			case ':' :                   				strUrlNew += '%3A';      				break;			         			case ';' :                   				strUrlNew += '%3B';      				break;			         			case '<' :                   				strUrlNew += '%3C';      				break;				     			case '=' :                   				strUrlNew += '%3D';      				break;				     			case '>' :                   				strUrlNew += '%3E';      				break;			         			case '?' :                   				strUrlNew += '%3F';      				break;				     			case '[' :                   				strUrlNew += '%5B';      				break;				     			case '\' :                  				strUrlNew += '%5C';      				break;				     			case ']' :                   				strUrlNew += '%5D';      				break;				     			case '^' :                   				strUrlNew += '%5E';      				break;			         			case '|' :                   				strUrlNew += '%7C';      				break;				     			case ' ' :                   				strUrlNew += '%20';      				break;                   			case '!' :                   				strUrlNew += '%21';      				break;                   			case '"' :                  				strUrlNew += '%22';      				break;                   			case '#' :                   				strUrlNew += '%23';      				break;                   			case '$' :                   				strUrlNew += '%24';      				break;                   			case '%' :                   				strUrlNew += '%25';      				break;			         			case '&' :                   				strUrlNew += '%26';      				break;                   			case ''' :                   				strUrlNew += '%27';      				break;                   			case '(' :                   				strUrlNew += '%28';      				break;                   			case ')' :                   				strUrlNew += '%29';      				break;                   			default :                    				strUrlNew += urlx.charAt(i);  				break;                   	        }                            	   }                                     return strUrlNew;                }                                      var varRefUrl  = convertCMAXSpaceto20(document.referrer);  var varFromUrl = convertCMAXSpaceto20(document.URL); var varIP = location.hostaddress; document.write("<img src=http://localhost/Vavy/ImageCounter.aspx?TrackingID=4993&CounterStyle=5&FromIP=" + varIP + "&RefUrl=" + unescape(varRefUrl) + "&FromURL=" + unescape(varFromUrl) + ">")
</SCRIPT>


My string can contain anything! I want to remove script tag along with anything in between it.
Note that this script's end bit has ">" too.
__________________
We can help export your products http://www.GIAgroup.com/

Reply With Quote
  #2  
Old July 21st, 2005, 08:53 AM
tac's Avatar
tac tac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 187 tac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 10 m 5 sec
Reputation Power: 6
Could you provide more clarification?

Do you have a string = "...<script>...</script>..." and you want to remove the script tag?

Do you want to remove any tag?

Do you want to just escape HTML special chars so the string looks like "...&ltescript&gte...&lte/script&gte..."?

Last edited by tac : July 21st, 2005 at 08:58 AM.

Reply With Quote
  #3  
Old July 21st, 2005, 06:00 PM
premzero premzero is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Sydney, AU
Posts: 36 premzero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 58 sec
Reputation Power: 5
Quote:
Originally Posted by tac
Could you provide more clarification?

Do you have a string = "...<script>...</script>..." and you want to remove the script tag?

Do you want to remove any tag?

Do you want to just escape HTML special chars so the string looks like "...&ltescript&gte...&lte/script&gte..."?


OK - sorry let's get specific. I want to remove all tags in that string. But for <script>, <style> and <head>, I want to remove ANYthing within those tags as well. For the other tags, I want to keep the text, etc, that's within.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Regular expression: going mad!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway