首页 > 学院 > 开发设计 > 正文

ASP正则匹配img标签

2019-11-17 04:13:57
字体:
来源:转载
供稿:网友

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

asp/Visual Basic代码:


 程序代码

<%
'***************************************************   
'*函数名 : GetImgFromContent   
'*参数说明 : html 被提取的html 代码   
'*功能简介 : 提取这部分html代码中的图片   
'*程序作者 : evio http://www.backci.cn/code
'*http://www.VeVb.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
%>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表