佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > 用正則表達式過濾html代碼

用正則表達式過濾html代碼

熱門標簽:阿里云 科大訊飛語音識別系統(tǒng) 團購網(wǎng)站 電子圍欄 銀行業(yè)務 服務器配置 Mysql連接數(shù)設置 Linux服務器

代碼例子如下:
%
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 lt; and gt;
 strOutput = Replace(strOutput, "", "lt;")
 strOutput = Replace(strOutput, ">", "gt;")

 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 %>

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

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

    • 400-1100-266
    临澧县| 华容县| 金湖县| 石门县| 册亨县| 五指山市| 文安县| 班戈县| 吉首市| 松潘县| 牡丹江市| 冀州市| 绥江县| 定陶县| 互助| 内乡县| 青浦区| 博罗县| 卫辉市| 山阳县| 肥西县| 内乡县| 梅州市| 吐鲁番市| 木兰县| 齐齐哈尔市| 玛曲县| 舟曲县| 嘉义县| 化州市| 泗阳县| 房产| 连平县| 龙井市| 阿城市| 玉龙| 鄢陵县| 大城县| 南京市| 贵南县| 财经|