欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp中获取内容中所有图片与获取内容中第一个图片的代码

程序员文章站 2022-05-18 11:29:51
复制代码 代码如下:'===================================== '获取内容中所有图片 '=========================...
复制代码 代码如下:

'=====================================
'获取内容中所有图片
'=====================================
function get_imgsrc(byval t0)
dim t1,regs,matches,match
t1=""
if not(isnull(t0) or len(t0)=0) then
set regs=new regexp
regs.pattern="<img[^>]+src=""([^"">]+)""[^>]*>"
regs.ignorecase=true
regs.global=true
set matches=regs.execute(t0)
if matches.count>0 then
for each match in matches
if left(match.submatches(0),7)<>"http://" then
t1=t1&"<option value="""&match.submatches(0)&""">"&match.submatches(0)&"</option>"
end if
next
end if
end if
get_imgsrc=t1
set matches=nothing
set regs=nothing
end function

'=====================================
'获取内容中第一个图片
'=====================================
function frist_pic(byval t0)
frist_pic=""
dim regs,matches
set regs=new regexp
regs.ignorecase=true
regs.global=true
regs.pattern="<img[^>]+src=""([^"">]+)""[^>]*>"
set matches=regs.execute(t0)
if regs.test(t0) then
frist_pic=matches(0).submatches(0)
end if
set matches=nothing
set regs=nothing
end function