国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > regex > 正文

用正則表達式過濾html代碼

2020-01-20 22:30:40
字體:
來源:轉載
供稿:網友

代碼例子如下:
<%
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 %>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沙湾县| 鄢陵县| 通河县| 秭归县| 高雄县| 西吉县| 大丰市| 孝义市| 漳州市| 灵川县| 金沙县| 芷江| 社旗县| 永新县| 山东省| 德钦县| 仙游县| 湾仔区| 桐乡市| 金沙县| 柳州市| 阿合奇县| 泉州市| 龙川县| 茂名市| 平利县| 舟曲县| 固原市| 潮安县| 英山县| 昌平区| 灵台县| 措勤县| 绥宁县| 七台河市| 壤塘县| 曲麻莱县| 延庆县| 清原| 安泽县| 溧水县|