Skip to content

Instantly share code, notes, and snippets.

@gwobcke
Created June 15, 2011 13:51

Revisions

  1. gwobcke created this gist Jun 15, 2011.
    16 changes: 16 additions & 0 deletions stripStringHTML.asp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <%
    FUNCTION stripHTML(strHTML)
    Dim objRegExp, strOutput, tempStr
    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 &lt; and &gt;
    strOutput = Replace(strOutput, "<", "&lt;")
    strOutput = Replace(strOutput, ">", "&gt;")
    stripHTML = strOutput 'Return the value of strOutput
    Set objRegExp = Nothing
    END FUNCTION
    %>