Function RemoveHTML( strText )
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
str = RegEx.Replace(strText, "")
str=replace(str," ","")
RemoveHTML =str
End Function
‘这个是去所有的,当然太多了,那就在这个之前先将asp 分段分行和空格进行替换 <p>替换成{p},</p>替换成{/p},<br>替换成{br},空格替换成{&nbsp}
如 str="<p>123<br>"
str=replace(str,"<p>","{/p}")
...
...
str=RemoveHTML(str)
再替换回来
str=replace(str,"{/p}","<p>")
Function Zxj_ReplaceHtml(patrn, strng,content)IF IsNull(content) Then
content=""
End IF
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = true
regEx.Global = True
Zxj_ReplaceHtml=regEx.Replace(content,strng)
End Function
Function ClearHtml(Content)
Content=Zxj_ReplaceHtml("[^>]*", "", Content)
Content=Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?object[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?param[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?embed[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?table[^>]*>", "", Content)
Content=Zxj_ReplaceHtml(" ","",Content)
Content=Zxj_ReplaceHtml("</?tr[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?th[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?td[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?script[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content)
Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content)
Content=Zxj_ReplaceHtml("<\\?xml[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("<\/?[a-z]+:[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?font[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?xml[^>]*>", "", Content)
Content=trim(Content)
Content=replace(Content,chr(9),"")
Content=replace(Content,chr(32),"")
Content=replace(Content,chr(34),"")
Content=replace(Content,chr(39),"")
Content=replace(Content,chr(10),"")
Content=replace(Content,chr(13),"")
Content=replace(Content," ","")
Content=replace(Content,"\r\n","")
ClearHtml=Content
End Function
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)