日期:2010-01-08  浏览次数:20826 次

<%
Option Explicit
'取得文章正文内容的所有图片地址
Function FormatImg(content)
dim re,mm,Match1,getimgs
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="<img.[^>]*src(= )(.[^>]*)>"

set mm=re.Execute(content) 
For Each Match1 in mm 
getimgs=getimgs&imgurl(Match1.Value)&""
'getimgs=imgurl(Match1.Value)
'exit for
next 
set re = nothing
FormatImg = server.HTMLEncode(getimgs)
End Function

Function imgurl(str)
 dim tmpstr
 if instr(str,"src=")>0 then
  tmpstr = split(str,"src=")(1)
  if instr(tmpstr,"""")>0 then
  tmpstr = split(tmpstr,"""")(1)
  end if
  if instr(tmpstr,"'")>0 then
  tmpstr = split(tmpstr,"'")(1)
  end if
 else
  tmpstr = ""
 end if
  imgurl = tmpstr
End Function

response.write FormatImg("<p>爱易学习网Web开发之家</p><script src=""http://www.aiyiweb.com/ads/ads.asp""></script><img border=""0"" alt="""" width=""556"" height=""1070"" src=""http://www.aiyiweb.com/adsview/UploadPic/2009-5/i4.gif"" /><div><center><a target=""_blank"" href=""http://www.aiyiweb.com/adsview/UploadPic/2009-5/i4.gif""><img border=""0"" alt="""" width=""556"" height=""1070"" src=""http://www.aiyiweb.com/adsview/UploadPic/2009-5/i2.gif"" /></a><br />爱易学习网Web开发之家<br /></center></div>")
%>