濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > asp中去除內(nèi)容HTML標(biāo)簽的三個(gè)function函數(shù)

asp中去除內(nèi)容HTML標(biāo)簽的三個(gè)function函數(shù)

熱門標(biāo)簽:離線電子地圖標(biāo)注軟件注冊(cè) 外呼回?fù)芟到y(tǒng)圖片 寧夏怎么申請(qǐng)400電話 蘭州智能語(yǔ)音電銷機(jī)器人功能 常用地圖標(biāo)注范圍點(diǎn) 咸陽(yáng)銷售外呼系統(tǒng) 為什么外呼系統(tǒng)需要預(yù)存話費(fèi)呢 辦理400電話一年多少錢 企數(shù)外呼系統(tǒng)能用多久
復(fù)制代碼 代碼如下:

'==============================
'功能描述: 用正則除去HTML標(biāo)記
'不能保留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標(biāo)記
'不能保留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標(biāo)記
'去除自定義的標(biāo)記,速度可能有點(diǎn)慢
'==============================

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

標(biāo)簽:溫州 昆明 咸陽(yáng) 麗江 家電維修 昌都 泰州 鐵嶺

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp中去除內(nèi)容HTML標(biāo)簽的三個(gè)function函數(shù)》,本文關(guān)鍵詞  asp,中,去除,內(nèi)容,HTML,標(biāo)簽,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp中去除內(nèi)容HTML標(biāo)簽的三個(gè)function函數(shù)》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp中去除內(nèi)容HTML標(biāo)簽的三個(gè)function函數(shù)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    吉首市| 九台市| 远安县| 社旗县| 馆陶县| 梅河口市| 杨浦区| 沧州市| 清远市| 偏关县| 十堰市| 临潭县| 洮南市| 元阳县| 延川县| 贡觉县| 蛟河市| 黔江区| 邵阳县| 酒泉市| 抚顺市| 伊宁市| 乌拉特中旗| 洞头县| 泸西县| 梓潼县| 大田县| 济源市| 尚志市| 新龙县| 洛南县| 聂荣县| 桐梓县| 广饶县| 石河子市| 平昌县| 元谋县| 江油市| 伽师县| 礼泉县| 博罗县|