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

ASP
asp中缓存cache技术的应用
escape解决AJAX中文乱码的简单方法
提高asp程序访问速度的方法
17个ASP编程基础典型代码
用asp编写类似搜索引擎功能的代码
ASP-server.URLEncode反函数:urldecode
判断远程图片是否存在的asp技巧
ASP采集-ASP采集程序原理
好用的asp防SQL注入代码
asp中提取HTML中图片的SRC路径
FileSystemObject 示例代码
asp动态页面生成html页面
ASP中的常用服务器检测源码
asp无组件上传并插入到数据库里
ASP+AJAX做类似google的搜索提示
asp的RegExp对象正则表达式功能用法
ASP怎样获得代码中第一张图片地址
ASP实现多域名同一空间的处理实例
ASP无组件上载,带进度条,多文件上载
用GetString来提高ASP的速度

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 47 ::
收藏到网摘: 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