用正则表达式写的HTML分离函数
用正则表达式写的HTML分离函数
发布时间:2016-12-29 来源:查字典编辑
摘要:存成.asp文件,执行,你用ASPHTTP抓内容的时候用这个很爽,当然自己要改进一下了EnteranHTMLString:0then%>Vi...

存成.asp文件,执行,你用ASPHTTP抓内容的时候用这个很爽,当然自己要改进一下了

<%

OptionExplicit

FunctionstripHTML(strHTML)

'StripstheHTMLtagsfromstrHTML

DimobjRegExp,strOutput

SetobjRegExp=NewRegexp

objRegExp.IgnoreCase=True

objRegExp.Global=True

objRegExp.Pattern="<.+?>"

'ReplaceallHTMLtagmatcheswiththeemptystring

strOutput=objRegExp.Replace(strHTML,"")

'Replaceall<and>with<and>

strOutput=Replace(strOutput,"<","<")

strOutput=Replace(strOutput,">",">")

stripHTML=strOutput'ReturnthevalueofstrOutput

SetobjRegExp=Nothing

EndFunction

%>

<formmethod="post"id=form1name=form1>

<b>EnteranHTMLString:</b><br>

<textareaname="txtHTML"cols="50"rows="8"wrap="virtual"><%=Request("txtHTML")%></textarea>

<p>

<inputtype="submit"value="StripHTMLTags!"id=submit1name=submit1>

</form>

<%ifLen(Request("txtHTML"))>0then%>

<p><hr><p>

<b><u>Viewofstring<i>withno</i>HTMLstripping:</u></b><br>

<xmp>

<%=Request("txtHTML")%>

</xmp><p>

<b><u>Viewofstring<i>with</i>HTMLstripping:</u></b><br>

<pre>

<%=StripHTML(Request("txtHTML"))%>

</pre>

<%EndIf%>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ASP教程学习
热门ASP教程学习
编程开发子分类