Remove HTML tags from a string
Function StripHTMLTags(ByVal sHTML)
Dim objRegExp, sOutput
sHTML = Trim(sHTML & "") 'Prevent Null errors
If Len(sHTML) > 0 Then
Set objRegExp = New RegExp
With objRegExp
.IgnoreCase = True
.Global = True
.Pattern = "<(.|\n)+?>"
' Replace all HTML tag matches With the Empty String
sOutput = .Replace(sHTML, "")
End With
Set objRegExp = Nothing
' Replace special characters With HTML equivalent
sOutput = Server.HTMLEncode(sOutput)
StripHTMLTags = sOutput
Else
StripHTMLTags = ""
End If
End Function![]()