用正则表达式过滤html代码
代码例子如下:
<%
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 %>
- 运用正则表达式在Asp中过滤Html标签代码的四种不同方法
- java代码用正则表达式去除html标签
- php正则过滤html标签、空格、换行符的代码,提取图片
- C#中可以使用正则表达式来过滤html字符
- Python通过正则表达式获取,去除(过滤)或者替换HTML标签的几种方法(本文由169it.com搜集整理)
- 正则表达式过滤HTML、JS、CSS
- 正则表达式过滤HTML危险脚本
- 正则表达式过滤HTML危险脚本
- ASP.NET正则表达式提取网页网址、标题、图片实例以及过滤所有HTML标签实例
- 【转】利用 正则表达式 过滤掉 textarea ,textbox里的html标签
- C# 正则表达式 过滤危险字符函数代码 防SQL注入 很全面的SQL关键字过滤
- C#使用正则表达式获取HTML代码中a标签里包含指定后缀的href的值
- C# 正则过滤html,js,css代码
- html过滤正则表达式
- asp.net 正则表达式过滤所有html标签
- linux c ip过滤 正则表达式 初步代码
- php正则表达式过滤html标签、空格、换行符
- java正则表达式过滤html标签
- 正则表达式过滤html标签