主页 > 知识库 > asp中去除内容HTML标签的三个function函数

asp中去除内容HTML标签的三个function函数

热门标签:离线电子地图标注软件注册 外呼回拨系统图片 宁夏怎么申请400电话 兰州智能语音电销机器人功能 常用地图标注范围点 咸阳销售外呼系统 为什么外呼系统需要预存话费呢 办理400电话一年多少钱 企数外呼系统能用多久
复制代码 代码如下:

'==============================
'功能描述: 用正则除去HTML标记
'不能保留b>strong>等以及用户自定义的和>
'==============================

Function RemoveHTMLTag(fString)
        Dim re
        Set re = New RegExp
        re.IgnoreCase = True
        re.Pattern = "(.[^>]*)>"
        fString = re.Replace(fString, "")
        Set re = Nothing
        RemoveHTMLTag = fString
End Function

'==============================
'功能描述: 除去HTML标记
'不能保留b>strong>等以及用户自定义的和>
'==============================

Function Remove_HTML(Str)
        Dim ilen1, ilen2
        Do While InStr(1, Str, "", 1) >0
                ilen1 = InStr(1, Str, "", 1)
                ilen2 = InStr(1, Str, ">", 1)
                Str = Left(Str, ilen1 -1)  Mid(Str, ilen2 + 1)
        Loop
        Remove_HTML = Str
End Function

'==============================
'功能描述: 除去HTML标记
'去除自定义的标记,速度可能有点慢
'==============================

Function RemoveHTML(strText)
        Dim TAGLIST
        TAGLIST = ";!--;!DOCTYPE;A;ACRONYM;ADDRESS;APPLET;AREA;B;BASE;BASEFONT;" _
        "BGSOUND;BIG;BLOCKQUOTE;BODY;BR;BUTTON;CAPTION;CENTER;CITE;CODE;" _
        "COL;COLGROUP;COMMENT;DD;DEL;DFN;DIR;DIV;DL;DT;EM;EMBED;FIELDSET;" _
        "FONT;FORM;FRAME;FRAMESET;HEAD;H1;H2;H3;H4;H5;H6;HR;HTML;I;IFRAME;IMG;" _
        "INPUT;INS;ISINDEX;KBD;LABEL;LAYER;LAGEND;LI;LINK;LISTING;MAP;MARQUEE;" _
        "MENU;META;NOBR;NOFRAMES;NOSCRIPT;OBJECT;OL;OPTION;P;PARAM;PLAINTEXT;" _
        "PRE;Q;S;SAMP;SCRIPT;Select;SMALL;SPAN;STRIKE;STRONG;STYLE;SUB;SUP;" _
        "TABLE;TBODY;TD;TEXTAREA;TFOOT;TH;THEAD;TITLE;TR;TT;U;UL;VAR;WBR;XMP;"

        Const BLOCKTAGLIST = ";APPLET;EMBED;FRAMESET;HEAD;NOFRAMES;NOSCRIPT;OBJECT;SCRIPT;STYLE;"

        Dim nPos1
        Dim nPos2
        Dim nPos3
        Dim strResult
        Dim strTagName
        Dim bRemove
        Dim bSearchForBlock

        nPos1 = InStr(strText, "")
        Do While nPos1 > 0
                nPos2 = InStr(nPos1 + 1, strText, ">")
                If nPos2 > 0 Then
                        strTagName = Mid(strText, nPos1 + 1, nPos2 - nPos1 - 1)
                        strTagName = Replace(Replace(strTagName, vbCr, " "), vbLf, " ")

                        nPos3 = InStr(strTagName, " ")
                        If nPos3 > 0 Then
                                strTagName = Left(strTagName, nPos3 - 1)
                        End If


                        If Left(strTagName, 1) = "/" Then
                                strTagName = Mid(strTagName, 2)
                                bSearchForBlock = False
                        Else
                                bSearchForBlock = True
                        End If

                        If InStr(1, TAGLIST, ";"  strTagName  ";", vbTextCompare) > 0 Then
                                bRemove = True
                                If bSearchForBlock Then
                                        If InStr(1, BLOCKTAGLIST, ";"  strTagName  ";", vbTextCompare) > 0 Then
                                                nPos2 = Len(strText)
                                                nPos3 = InStr(nPos1 + 1, strText, "/"  strTagName, vbTextCompare)
                                                If nPos3 > 0 Then
                                                        nPos3 = InStr(nPos3 + 1, strText, ">")
                                                End If

                                                If nPos3 > 0 Then
                                                        nPos2 = nPos3
                                                End If
                                        End If
                                End If
                        Else
                                bRemove = False
                        End If

                        If bRemove Then
                                strResult = strResult  Left(strText, nPos1 - 1)
                                strText = Mid(strText, nPos2 + 1)
                        Else
                                strResult = strResult  Left(strText, nPos1)
                                strText = Mid(strText, nPos1 + 1)
                        End If
                Else
                        strResult = strResult  strText
                        strText = ""
                End If

                nPos1 = InStr(strText, "")
        Loop
        strResult = strResult  strText
        strResult = Replace(strResult, Chr(9), "")
        strResult = Replace(strResult, Chr(32), "")
        strResult = Replace(strResult, Chr(13), "")
        strResult = Replace(strResult, Chr(10), "")
        strResult = Replace(strResult, vbCrLf, "")
        RemoveHTML = strResult
End Function

标签:温州 昆明 咸阳 丽江 家电维修 昌都 泰州 铁岭

巨人网络通讯声明:本文标题《asp中去除内容HTML标签的三个function函数》,本文关键词  asp,中,去除,内容,HTML,标签,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《asp中去除内容HTML标签的三个function函数》相关的同类信息!
  • 本页收集关于asp中去除内容HTML标签的三个function函数的相关信息资讯供网民参考!
  • 推荐文章