凤来仪

专业的计算机学习网站

首页 > ASP获取内容中所有图片

ASP获取内容中所有图片

点击:33 发布时间:

ASP获取内容中所有图片:

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