脚本宝典收集整理的这篇文章主要介绍了好东西,老外用正则表达式写的HTML分离函数,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
存成.asp文件,执行,你用ASPHTTP抓内容的时候用这个很爽,当然自己要改进一下了
<%
Option E
xplic
ITFunction stripHT
ML(strHTML)
'Strips the HTML tags
From strHTML
&nbs
p; 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 n
ame=form1>
<b>Enter an HTML String:</b><
br>
<textarea name="txtHTML" cols="50" rows="8" wrap="virtual"><%=Request("txtHTML")%></textarea>
<p>
<input ty
PE="s
ubmit" 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分离函数所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。