网站首页 > 书籍教程 > ASP教程 > ASP正则匹配img标签

ASP正则匹配img标签

  • 作者:互联网
  • 时间:2009-06-26 18:10:31

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

ASP/Visual Basic代码:


 程序代码

<%
'***************************************************   
'*函数名 : GetImgFromContent   
'*参数说明 : html 被提取的html 代码   
'*功能简介 : 提取这部分html代码中的图片   
'*程序作者 : evio http://www.backci.cn/code
'*http://www.downcodes.com/  
'***************************************************   
function GetImgFromContent(html)   
    Dim Re, match, matchs, htm, t   
    htm = ""  
    set Re = new RegExp   
    re***noreCase =True    
    re***obal = True    
    re***ttern = "]*>" '--]*>   
    Set matchs = re***ecute(html)   
    for each match in matchs   
        htm = htm + (ma***.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 = ""  
end function
%>