您的位置:首页 > 编程语言 > ASP

ASP提取文章中的所有图片

2012-03-09 00:00 204 查看
提取一段内容中的所有图片或者图片地址
<%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"" />


$(document).ready(function(){dp.SyntaxHighlighter.HighlightAll('code');});

原文链接:
http://blog.csdn.net/vince6799/article/details/6765283
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: