在Asp中(用正则表达式)获取文章中的图片地址

4/16/2009来源:ASP技巧人气:8616

<%
dim result,result1
str="adfjlmnnzlkjlkfjoj <img src=""http://img.knowsky.com/img/logo.jpg"" border=0 width=100>dfkjhdjfk"
set re=new regexp
re.ignorecase=true
re.global=true
re.pattern="<img [^>]*src=""([^"">]+)""[^>]+>"
set m=re.execute(str)
for each n in m
result=result&n&"|"
result1=result1&n.submatches(0)&"|"
next
set m=nothing
set re=nothing
if result<>"" then
result=left(result,len(result)-1)
result1=left(result1,len(result1)-1)
end if
result=split(result,"|") '存储<img>
result1=split(result1,"|") '存储图像地址
%>