VBS取出(提取)一段文本里的所有图片地址[正则表达式实现]

<script language = vbs>
Str = "<img src=""123.Gif"" alt=""dsddfsa"" >     <img src=""123.jpG"" > <img src=""123.jpg""><IMG SRC=123.JPG>"
'使用方法:把这个文件存为getImages.vbs,然后运行便可看到效果

Function getImages(Str)
      Set re = New RegExp
      re.Pattern = "<img(.+?)src=""*([^\s]+?)""*(\s|>)"
      re.Global = True
      re.IgnoreCase = True
      Set Contents = re.Execute(Str)
      For Each Match in Contents ' 遍历匹配集合。
          Images = Images + Match.SubMatches(1) + "|"
      Next
      getImages = Mid(Images, 1, Len(Images) -1)
End Function

MsgBox(getImages(Str))
</script>


评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.