日期:2014-05-17 浏览次数:21314 次
Function GetFirstImg(Str) '取得img 标签内容
Dim tmp
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True '忽略大小写
objRegExp.Global = false '全文搜索 !关键!
objRegExp.Pattern = "<img (.*?)src=(.[^\[^>]*)(.*?)>"
Set Matches = objRegExp.Execute(Str)
For Each Match in Matches
tmp = tmp & Match.Value
Next
GetFirstImg = GetImgS(tmp)
End Function
Function GetImgS(Str)'获取所有图片
Set objRegExp1 = New Regexp
objRegExp1.IgnoreCase = True '忽略大小写
objRegExp1.Global = True '全文搜索
objRegExp1.Pattern = "src\=.+?\.(gif|jpg|png|bmp)"
Set mm = objRegExp1.Execute(Str)
For Each Match1 in mm
imgsrc = Match1.Value
'也许存在不能过滤的字符,确保万一
imgsrc = Replace(imgsrc, """", "")
imgsrc = Replace(imgsrc, "src=", "")
imgsrc = Replace(imgsrc, "<", "")
imgsrc = Replace(imgsrc, ">", "")
imgsrc = Replace(imgsrc, "img", "")
imgsrc = Replace(imgsrc, " ", "")
GetImgS = GetImgS & imgsrc'把里面的地址串起来备用
Next
End Function