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

作者:佚名 来源:12it.net 时间:2008-10-29 09:40:00 




           

'把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]+)&ldquo;
        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=http://www.chinaz.com/Program/Asp/""1.gif"">"
pic = toppic(code1,"html","nopic.gif")
response.Write pic

标签:
0
投稿

猜你喜欢

  • 可以输入的下拉菜单

    2009-01-04 14:21:00
  • ASP实现数据输入、查询的实例

    2010-05-03 10:48:00
  • SQL数据库操作类

    2009-01-14 16:26:00
  • 在select语句中使用top的一些小技巧

    2009-03-12 12:21:00
  • MySQL安全问题的一点心得

    2009-01-07 16:13:00
  • MYSQL中怎样设列的默认值为Now()的介绍

    2008-11-01 16:54:00
  • SQL Server 作业的备份(备份作业非备份数据库)

    2012-07-11 15:58:49
  • 理解和使用Oracle 8i分析工具LogMiner

    2010-07-16 13:22:00
  • SQL Server 2005中利用xml拆分字符串序列

    2009-01-06 11:30:00
  • 如何使用SQL Server中的客户端配置工具

    2009-01-13 14:05:00
  • dl,dt,dd标签 VS 传统table实现数据列表

    2009-08-02 20:45:00
  • ASP 自动采集实现代码

    2011-03-07 11:17:00
  • 如何不通过DSN访问SQL Server?

    2009-11-11 19:21:00
  • 深入研究Application和Session对象

    2008-10-13 08:30:00
  • ASP网站Server object error的解决办法

    2008-11-07 15:57:00
  • 模拟兼容性的 inline-block 属性

    2008-04-08 12:37:00
  • MySQL数据库的root口令恢复方法总结

    2009-08-19 09:03:00
  • 让IE8支持eWebEditor在线编辑器

    2010-02-28 10:36:00
  • 利用global.asa计划执行程序

    2008-03-05 12:49:00
  • 使用AJAX的一个简单的例子

    2007-09-21 17:55:00
  • asp之家 网络编程 m.aspxhome.com