Your Ad Here

Posted By

Scooter on 12/20/08


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

benrudolph


strip_tags()


 / Published in: ASP
 

URL: http://reusablecode.blogspot.com/2008/12/striptags.html

Strip all HTML/ASP/PHP tags from a string; essential for validating user input. (But not solely sufficient for validating user input. Use additional methods as appropriate.)

  1. <%
  2. ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
  3. '
  4. ' This work is licensed under the Creative Commons Attribution License. To view
  5. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  6. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  7. ' 94305, USA.
  8.  
  9. ' Strip HTML/ASP/PHP tags from a string.
  10. function strip_tags(unsafeString)
  11. dim regEx
  12.  
  13. set regEx = new RegExp
  14.  
  15. with regEx
  16. .Global = true
  17. .IgnoreCase = true
  18. .Pattern = "(\<(/?[^\>]+)\>)"
  19. end with
  20.  
  21. strip_tags = regEx.Replace(unsafeString, "")
  22.  
  23. set regEx = nothing
  24. end function
  25. %>

Report this snippet  

You need to login to post a comment.