正则表达式为什么没有过滤这代码??

arendt2001 2006-06-12 01:28:38
我用的是以下正则表达式

Function stripHTML(strHTML)
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>" '代表<.......>
strOutput = objRegExp.Replace(strHTML, "")'是替换啊,把<.+?>替换为""不显示,你可以使用"*"看效果
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")
stripHTML = strOutput
Set objRegExp = Nothing
End Function

但是我读数据库的值是还有有这样的标签,如下是我从数据库中用正则表达式读出的数据:
screen.width-333)this.width=screen.width-333" border=0>新款风扇 screen.width-333)this.width=screen.width-333" border=0>海尔的整体厨房 screen.width-333)this.width=screen.width-333" border=0>海尔的整体厨房 screen.width-333)this.width=screen.width-333" border=0>精美的电熨斗 screen.width-333)this.width=screen.width-333" border=0>各
...全文
109 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SysTem128 2006-06-12
  • 打赏
  • 举报
回复
Function stripHTML(strHTML)
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<(.*?)>" '代表<.......>
strOutput = objRegExp.Replace(strHTML, "")'是替换啊,把<.+?>替换为""不显示,你可以使用"*"看效果
strOutput = Replace(strOutput, "<", "")
strOutput = Replace(strOutput, ">", "")
stripHTML = strOutput
Set objRegExp = Nothing
End Function

这样就可以把 HTML标签全部去处掉……
wanghui0380 2006-06-12
  • 打赏
  • 举报
回复
可以用 <[^<>]+> 试试看
xieqi 2006-06-12
  • 打赏
  • 举报
回复
.要转义。它有特殊含义

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧