日期:2014-05-17 浏览次数:21122 次
Function RemoveHTML(strHTML) Dim objRegExp, Match, Matches Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "(\<.[^\<]*\>)" Set Matches = objRegExp.Execute(strHTML) For Each Match in Matches strHtml=Replace(strHTML,Match.Value,"") Next RemoveHTML=strHTML Set objRegExp = Nothing End Function
<script language="JavaScript"> <!-- var country="楼主" //--> </script> <style type="text/css"> .myname{font-family:"饿了";} </style> <table><tr><td>哇塞</td></tr></table> <iframe src=".............." title="还在加班"></iframe> <OBJECT src="..............">郁闷啊</OBJECT> <!-- 注释 我的<b>毅力</b>很强 --> <p> <font color=red>注意了:</font> 100只<i>鸡</i> < 200只<i>鸡</i> > 50只<i>鸡</i> = 一百只<i>鸡</i> </p>
哇塞 注意了: 100只鸡 < 200只鸡 > 50只鸡 = 一百只鸡
<textarea id="sss" rows="10" cols="100"></textarea> <SCRIPT Language="VBScript"> Function RemoveHTML(strHTML) Dim objRegExp, Match, Matches Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<(.[^\<]*)>(.[^\<\1]*)<\/\1>" RemoveHTML = objRegExp.Replace(strHTML,"$2") Set objRegExp = Nothing End Function sss.value = RemoveHTML("100只<i>鸡</i> < 200只<i>鸡</i> > 50只<i>鸡</i> = 一百只<i>鸡</i>")
------解决方案--------------------
这些文本是你在文本编辑器里面输入的?预先排好格式的吗?
------解决方案--------------------
只删除标签:
<textarea id="sss" rows="10" cols="100"></textarea> <SCRIPT Language="VBScript"> Function RemoveHTML(strHTML) Dim objRegExp, Match, Matches Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<.[^\s|^<]*>" RemoveHTML = objRegExp.Replace(strHTML,"") Set objRegExp = Nothing End Function sss.value = RemoveHTML("100只<i>鸡<