教学之友,学习之友。

站长教学网

当前位置: 站长教学网 > 网站编程 > ASP教程 >

asp如何获得代码中第一张图片地址

时间:2012-03-29 16:14来源:未知 作者:ken 点击:

'把pattern 又修改了下
'code要检测的代码
'leixing html 或者ubb
'nopic 代码没有图片时默认值
'站长教学网 eduyo.com
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

(责任编辑:ken)
TAG标签: asp 正则 代码
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
注册登录:不允许匿名留言,登录后留言无需输入验证码。
栏目列表
最新内容