袁来如此的工作笔记
袁来如此的工作笔记
竹杖芒鞋轻胜马,谁怕? 一蓑烟雨任平生。

asp获取文章中的图片函数

浏览量:1018

'===================================== 

'获取内容中第一个图片 

'===================================== 

Function GetFirstImg(ByVal t0) 

GetFirstImg="" 

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 

GetFirstImg=Matches(0).SubMatches(0) 

End IF 

Set Matches=Nothing 

Set Regs=Nothing 

End Function


'===================================== 

'获取内容中所有图片 

'===================================== 

Function GetImgS(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 

GetImgS=t1 

Set Matches=Nothing 

Set Regs=Nothing 

End Function 


打赏