鹅不食草滴鼻后流鼻涕:ASP高难问题

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 17:51:37
如:<p><img src="*****"><br>文字文字文字文字文字<img onmousewheel="return zoom_img(event,this)" alt="" src="UploadFiles/2006-7/200672975338566.jpg" onload="javascript:if(this.width>740)this.width=740><font size=2>文字文字</font></p>;
现在要去掉该字符串中类如<img src="*****">(图片),保留图片以外的文字和HTML代码,请问应该如何实现?

用正则式吧。我只知道怎么去掉所有的HTML代码,给你参考一下吧。
Function delHtml(strHtml)'去除代码

Dim objRegExp, strOutput
Set objRegExp = New Regexp

objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "(<[a-zA-Z].*?>)|(<[\/][a-zA-Z].*?>)"

strOutput = objRegExp.Replace(strHtml, "")
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")
delHtml = strOutput

Set objRegExp = Nothing
End Function
'用正则式去掉HTML代码