去掉html的正则表达式

<%
  aaa = "国首家荣获新生产工艺专&nbsp;&nbsp;&nbsp;利企业<BR>&nbsp;&nbsp;——成功的背后<BR><BR>2008年6月13日,深圳松<BR>钮扣<p>收到艺专利企业<BR>——松记钮扣成功的背后<BR><BR>2008年6月13日,深圳松记钮扣</p>收到了国家知识产权局颁布的发明专利实质审查程序通知书,这标志着松记钮扣申请的生产已进入!"

Function RemoveHTML(s)
  If Len(""&s)=0 Then RemoveHTML="" : Exit Function
  Dim r,match,matches
  Set r=New RegExp
  r.IgnoreCase = True
  r.Global = True
  r.Pattern = "<.+?>"
  Set matches = r.Execute(s)
  For Each match In matches
    s=Replace(s,match.value,"")
  Next
  r.Pattern = "\\s"
  Set matches = r.Execute(s)
  For Each match In matches
    s=Replace(s,match.value,"")
  Next

  \'s = Replace(s,"&nbsp;","")
  r.Pattern = "\\&nbsp;"
  s = r.Replace(s,"")
  RemoveHTML = s
  Set r=Nothing
End Function


Public Function RemoveHTML0(str)
   if isnull(str) or str="" then exit function
    dim reg,sstr
    set reg = New RegExp
    reg.Global  = true
    reg.IgnoreCase = true

    reg.Pattern = "/<[^<>]+>/"
    str = reg.Replace(str,"")

    reg.Pattern = "\\s"
    str = reg.Replace(str,"")

    reg.Pattern = "\\&nbsp;"
    str = reg.Replace(str,"")

    RemoveHTML0 = str
    set reg = Nothing
End  Function


Function RemoveHTML1(s)
  if isnull(s) or s="" then exit function
  Dim r,match,matches
  Set r=New RegExp
  r.IgnoreCase = True
  r.Global = True
  r.Pattern = "<.+?>"
    s=r.Replace(s,"")

  r.Pattern = "\\s"
    s=r.Replace(s,"")

  r.Pattern = "\\&nbsp;"
  s = r.Replace(s,"")
  RemoveHTML1 = s
  Set r=Nothing
End Function

  response.write(RemoveHTML0(aaa))
  response.write(RemoveHTML(aaa))
  response.write(RemoveHTML1(aaa))
%>
自己运行一下看看效果吧。然后调动顺序。再看一下效果。
300*300
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00454 秒