Stripping HTML tags
January 13, 2008This is one cool and useful piece of code for maybe any web developer. In this code, the HTML tag is being stripped of a string, in order to display an html-formatted entry as plain text.
Dim strInput, strOutput, objRegEx
strInput =”This is a bunch of text in <b>BOLD</b>, <i>Italic</i>, <br> yadayaya…<br><br>”
Response.write(”<b>HTML TEXT TO BE CLEANED:</b><br>”)
Response.write(strInput)
Set objRegEx = New RegExp
objRegEx.Pattern = “<[^>]*>”
objRegEx.Global = true
strOutput = objRegEx.Replace(strInput, “”)
Response.write(”<b>CLEANED UP TEXT:</b><br>”)
Response.write(strOutput)
However, if there needs to be more code, please do share in comments.
Posted by Vishal Reddy