asp/vbscript 函数RemoveHTML(),正则表达式高效删除所有html标签,包括javascript及CSS标签<script…>xxx</script>与<style…>xxx</style>
”删除字符串中所有html标记,包括javascript及css代码区块,同时删除换行符
” by fengyqf 20100929
Function RemoveHTML(str)
Dim objRegExp, Match,strHTML
if isnull(str) then
str=””
end if
strHTML=str
strHTML=replace(replace(replace(strHTML,vblf,””),vbcr,””),vbcrlf,””)
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = “<script[^>]*?>.*?</script>”
strHTML = objRegExp.Replace(strHTML,””)
objRegExp.Pattern = “<style[^>]*?>.*?</style>”
strHTML = objRegExp.Replace(strHTML,””)
objRegExp.Pattern = “<.+?>”
strHTML = objRegExp.Replace(strHTML,””)
Set objRegExp = Nothing
RemoveHTML=strHTML
End Function

延伸阅读
- asp/vbscript版Base64函数/Base64编码Base64encode解码Base64decode
- php与asp/vbscript对input表单数组的处理比较
- asp vbscript报错“字符串空间不够”
- 常见错误 不能打开注册表关键字 'Temporary (volatile) Jet DSN 解决方法/asp+access
- vbscript/asp函数:extract_by_str,指定起止字符串在字符串中截取子串
- “常见错误 不能打开注册表关键字” 与 “Provider 错误 ’80004005′ 未指定的错误”解决手记
- windows 2003 iis6 修改上传文件大小
- 使用host文件完美解决ASP错误msxml3.dll 错误 '800c0005'
- windows下配置apache支持运行asp
- 不引用外部图片文件,实现往网页html里插入图片
- Jeremy Keith演讲稿:HTML5的设计
- fedora14下apache(httpd)MIME文件
- Html5新标签解释及用法
- HTML5 Shiv – 让该死的IE系列支持HTML5
- Html 5 新特性_布局新标签
0 条评论。