提取一段内容中的所有图片或者图片地址
<%Function RegImg(TheStr)
Dim RegEx
Set RegEx = New RegExp
RegEx.IgnoreCase =True
RegEx.Global = True
RegEx.Pattern = "<img[^>]*src\s*=\s*['"&CHR(34)&"]?([\w/\-\:.]*)['"&CHR(34)&"]?[^>]*>"
If Regex.test(TheStr) then
Dim Matches
Set Matches = RegEx.Execute(TheStr) ' 执行搜索。
For Each Match in Matches ' 遍历匹配集合。
RetStr = RetStr & Match.Value & "<br />" '获取整个img
RetStr = RetStr & Match.SubMatches(0) '只取src
Next
RegImg = RetStr
End If
End Function%>
调用方法:
Response.Write RegImg("<p><img src="" http://avatar.csdn.net/E/D/9/3_vince6799.jpg"" alt=""vince6799"" />