
<%
Function gameimgs(content)
Set regEx = New RegExp '建立正則表達(dá)式。
regEx.Pattern = "(<img)(.[^<>]*)(src=)('|"&CHR(34)&"| )?(.[^'|\s|"&CHR(34)&"]*)(\.)(jpg|gif|png|bmp|jpeg)('|"&CHR(34)&"|\s|>)(.[^>]*)(>)" '設(shè)置模式。
regEx.IgnoreCase = True '設(shè)置是否區(qū)分字符大小寫(xiě)。
regEx.Global = True '設(shè)置全局可用性。
Set Matches = regEx.Execute(content) '執(zhí)行搜索。
For Each Match in Matches '遍歷匹配集合。
'輸入圖片地址
'Response.Write Match.SubMatches(4)&"."&Match.SubMatches(6)
gameimgs = Match.SubMatches(4)&"."&Match.SubMatches(6)
Next
End Function
%>
<ol>
<%
set imgrs=server.CreateObject("adodb.recordset")
imgrs.open "select * from news",conn,1,3
if imgrs.eof and imgrs.bof then
response.write "111"
else
do until imgrs.eof
response.write "<li>"& imgrs("title")
imgrs("saveimg") = gameimgs(imgrs("game"))
imgrs("img") = gameimgs(imgrs("game"))
response.write "</li>"
imgrs.update
imgrs.movenext
loop
end if
imgrs.close
set imgrs=nothing
%>
</ol>
<%conn.close:set conn=nothing%>
利用ASP正則提取文章里面的圖片的有效的src地址的示例
您發(fā)布的評(píng)論即表示同意遵守以下條款:
一、不得利用本站危害國(guó)家安全、泄露國(guó)家秘密,不得侵犯國(guó)家、社會(huì)、集體和公民的合法權(quán)益;
二、不得發(fā)布國(guó)家法律、法規(guī)明令禁止的內(nèi)容;互相尊重,對(duì)自己在本站的言論和行為負(fù)責(zé);
三、本站對(duì)您所發(fā)布內(nèi)容擁有處置權(quán)。