spacer
Janet Systems DotNetNuke Websites, Hosting, Custom Servers
Tag Words
spacer
ASP Articles

A short function which may be used to strip HTML tags from a string.

Function StripHTMLTags(ByVal sHTML)
    Dim objRegExp
    Dim sOutput
    sHTML = Trim(sHTML & "")
    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

strValue = StripHTMLTags(strString)

  This article viewed: 2942 times Back

Copyright © 2004-2009 Janet Systems Ltd.

    spacer
    Print