好东西,老外用正则表达式写的HTML分离函数

人生坎坎坷坷,跌跌撞撞那是在所难免。但是,不论跌了多少次,你都要坚强地再次站起来。再试一次,成功一定属于你!
存成.asp文件,执行,你用ASPHTTP抓内容的时候用这个很爽,当然自己要改进一下了<%
Option ExplicitFunction stripHTML(strHTML)
'Strips the HTML tags from strHTMLDim objRegExp, strOutput
Set objRegExp = New RegexpobjRegExp.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 strOutputSet 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 %>

到此这篇关于好东西,老外用正则表达式写的HTML分离函数就介绍到这了。抱最大的希望,为最大的努力,做最坏的打算。更多相关好东西,老外用正则表达式写的HTML分离函数内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

您可能有感兴趣的文章
浅析golang 正则表达式

基于xpath选择器、PyQuery、正则表达式的格式清理工具详解

javascript正则表达式 限1-2位整数,或者至多含有两位小数的写法

正则表达式中的 .*? 或 .*+ 的意思

javascript正则表达式标记中/g /i /m的用法,以及实例