当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP怎样可以获得代码中第一张图片地址

ASP
ASP基础讲座(下)
解决IIS5 HTTP500内部错误
ASP 3.0高级编程(四十六)
ASP 3.0高级编程(四十五)
ASP 3.0高级编程(四十四)
ASP 3.0高级编程(四十三)
ASP 3.0高级编程(四十二)
ASP 3.0高级编程(四十一)
ASP 3.0高级编程(三十九)
ASP 3.0高级编程(三十八)
ASP 3.0高级编程(三十七)
ASP 3.0高级编程(三十六)
ASP 3.0高级编程(三十五)
ASP 3.0高级编程(三十四)
ASP 3.0高级编程(三十三)
ASP 3.0高级编程(三十二)
ASP 3.0高级编程(三十一)
ASP错误代码说明
jscript错误代码及相应解释大全
ASP错误处理

ASP怎样可以获得代码中第一张图片地址


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 55 ::
收藏到网摘: n/a

'把pattern 又修改了下
'code要检测的代码
'http://www.knowsky.com/asp.asp
'leixing html 或者ubb
'nopic 代码没有图片时默认值
function toppic(code,leixing,nopic)
        set regex = new regexp
        regex.ignorecase = true
        regex.global = true
        if leixing = "html" then
                regex.pattern = "<img(.*?)src\s?\=\s?(\u0022?)([^\u0022\/>]+)"
        else
                regex.pattern = "\[img\]([^\u005B]+)“
        end if
        set matches = regex.execute(code)
        if regex.test(code) then
                                  if leixing = "html" then
                           toppic = matches(0).submatches(3)
                                  else
                                           toppic = matches(0).submatches(0)
                                  end if
        else
                toppic = nopic
        end if
end function
code1 = "<img src=""1.gif"">"
pic = toppic(code1,"html","nopic.gif")
response.Write pic