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

ASP
asp利用dictionary创建二维数组
ASP + Serv-u 实现FTP的代码
asp获取数据库中所有表名和字段名
SITEMAP生成程序的ASP实现
通过XMLHTTP实现模板式静态页生成
实践xml缓存技术构建高性能web站点
一个简单好用的UBB编辑器(含代码)
使用ASP脚本命令重新启动服务器
技巧:用ASP在线创建Word与Excel文档
ASP.NET后台代码实现XmlHttp跨域访问
浅析 ASP.NET编程中的十大技巧
用ASP实现IE地址栏参数的判断
ASP调用SQL Server视图和存储过程
应用:用ASP实现在线文章翻译的功能
ASP实现无组件生成验证码-GIF格式
ASP实现长文章自动分页的函数代码
深入研究Application和Session对象
提高ASP的速度的方法:GetString
ASP进阶教程Ⅶ:留言簿设置密码验证
asp获取文件md5值

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


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