A classic ASP function to remove the HTML tags from a given string.
Function StripHTMLTags(ByVal sHTML)
Dim objRegExp
Dim sOutput
sHTML = Trim(sHTML & "")
'Check to ensure that the string has length
If Len(sHTML) > 0 Then
Set objRegExp = New RegExp
With objRegExp
.IgnoreCase = True
.Global = True
.Pattern= "<[^>]+>"
sOutput = .Replace(sHTML, "")
End With
Set objRegExp = Nothing
sOutput = Server.HTMLEncode(sOutput)
StripHTMLTags = sOutput
Else
StripHTMLTags = ""
End If
End Function
The function should be called as follows:
nString = StripHTMLTags(oString)
Where nString is the new modified string and oString is the original string with the HTML tags.


