在Asp中(用正则表达式)获取文章中的图片地址
2009-04-16 10:39:13 来源:WEB开发网核心提示:<% dim result,result1 str="adfjlmnnzlkjlkfjoj <img src=""http://tech.cncms.com/tech/UploadPic/2010-9/201098103913907.jpg"" border
<%
dim result,result1
str="adfjlmnnzlkjlkfjoj <img src=""http://tech.cncms.com/tech/UploadPic/2010-9/201098103913907.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,"|") '存储图像地址
%>
dim result,result1
str="adfjlmnnzlkjlkfjoj <img src=""http://tech.cncms.com/tech/UploadPic/2010-9/201098103913907.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,"|") '存储图像地址
%>
[]
更多精彩
赞助商链接