·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP网站建设 >> ASP正则匹配img标签

ASP正则匹配img标签

作者:佚名      ASP网站建设编辑:admin      更新时间:2022-07-23

可以模仿QQ空间里有图片的话就在标题后显示有附件的图片

asp/Visual Basic代码:


 程序代码

<%
'***************************************************   
'*函数名 : GetImgFromContent   
'*参数说明 : html 被提取的html 代码   
'*功能简介 : 提取这部分html代码中的图片   
'*程序作者 : evio http://www.backci.cn/code
'*http://www.knowsky.com/  
'***************************************************   
function GetImgFromContent(html)   
    Dim Re, match, matchs, htm, t   
    htm = ""  
    set Re = new RegExp   
    re.IgnoreCase =True    
    re.Global = True    
    re.Pattern = "<img [^<]*src=""(.*)""[^>]*>" '--<img [^<]*src=""(.*)""[^>]*>   
    Set matchs = re.Execute(html)   
    for each match in matchs   
        htm = htm + (match.SubMatches(0)) & "|$|"  
    next   
    set matchs = nothing   
    t = split(htm, "|$|")(0)   
    if len(t) = 0 or t = "" then   
        t = "_template_Images/PRive.jpg"  
    end if   
    ze = "<img src='" & t & "' width='191' height='119' />"  
end function
%>