主頁 > 知識庫 > 用正則表達(dá)式寫的HTML分離函數(shù)

用正則表達(dá)式寫的HTML分離函數(shù)

熱門標(biāo)簽:服務(wù)器配置 銀行業(yè)務(wù) Linux服務(wù)器 Mysql連接數(shù)設(shè)置 科大訊飛語音識別系統(tǒng) 阿里云 電子圍欄 團(tuán)購網(wǎng)站
存成.asp文件,執(zhí)行,你用ASPHTTP抓內(nèi)容的時候用這個很爽,當(dāng)然自己要改進(jìn)一下了

%
Option Explicit

Function stripHTML(strHTML)
'Strips the HTML tags from strHTML

Dim objRegExp, strOutput
Set objRegExp = New Regexp

objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = ".+?>"

'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")

'Replace all  and > with  and >
strOutput = Replace(strOutput, "", "")
strOutput = Replace(strOutput, ">", ">")

stripHTML = strOutput 'Return the value of strOutput

Set objRegExp = Nothing
End Function


%>

form method="post" id=form1 name=form1>
b>Enter an HTML String:/b>br>
textarea name="txtHTML" cols="50" rows="8" wrap="virtual">%=Request("txtHTML")%>/textarea>
p>
input type="submit" value="Strip HTML Tags!" id=submit1 name=submit1>
/form>

% if Len(Request("txtHTML")) > 0 then %>
p>hr>p>
b>u>View of string i>with no/i> HTML stripping:/u>/b>br>
xmp>
%=Request("txtHTML")%>
/xmp>p>
b>u>View of string i>with/i> HTML stripping:/u>/b>br>
pre>
%=StripHTML(Request("txtHTML"))%>
/pre>
% End If %>

標(biāo)簽:衡水 衢州 江蘇 萍鄉(xiāng) 廣元 棗莊 蚌埠 大理

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用正則表達(dá)式寫的HTML分離函數(shù)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266