提取字符串中的图片地址

DATE: 2016-11-10 / VIEWS: 754

应用:
Content="<img height=11 src=http://a.gif width=10>adfas<img height=11 src=v.gif width=10>dfasf"
response.write savepic(Content)
response.end()

程序代码 程序代码
function savepic(str)
content=str&""
regstr="src\=.+?\.(gif|jpg)"
url=Replace(Replace(Replace(RegExp_Execute(regstr,content),"'",""),"""",""),"src=","")
savepic=url
end function
Function RegExp_Execute(patrn, strng)
Dim regEx, Match, Matches,values '建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = patrn '设置模式。
regEx.IgnoreCase = true '设置是否区分字符大小写。
regEx.Global = True '设置全局可用性。
Set Matches = regEx.Execute(strng) '执行搜索。
For Each Match in Matches '遍历匹配集合。
values=values&Match.Value&","
Next
RegExp_Execute = values
End Function