
Published in Website Design on Wednesday, 22 April 2009 |
Post RSS
This ASP function can be used to strip the HTML from a string - useful when listing summaries of items / pages in a database or displaying RSS feeds on your website.
Use the following function in your ASP code:
Function stripHTML(strHTML) 'Strips the HTML tags from strHTML
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<(.|\n)+?>"
'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")
'Replace all < and > with < and >
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")
stripHTML = strOutput 'Return the value of strOutput
Set objRegExp = Nothing
End Function
Then call it on your page like this:
<%= stripHTML(theHtmlToStrip) %>
Whatever your business needs, one of our highly trained small business development experts is sure to be able to help.
Welcome to WebFertile. We'd love you to join us and benefit from:
View project briefs, client comments + latest Google® performance.
WebFertile
The Hive Business Centre
NTU Buildings
Burton Street
Nottingham
NG1 4BU
0115 849 2660
07973 122 619