图像地址正则问题

functiontoppic(code,leixing,nopic)setregex=newregexpregex.ignorecase=trueregex.global... function toppic(code,leixing,nopic)
set regex = new regexp
regex.ignorecase = true
regex.global = true
if leixing = "html" then
regex.pattern = "<img(.*?)src\s?\=\s?(\u0022?)([^\u0022\/>]+)"
else
regex.pattern = "\[img\]([^\u005B]+)"
end if
set matches = regex.execute(code)
if regex.test(code) then
if leixing = "html" then
toppic = matches(0).submatches(3)
else
toppic = matches(0).submatches(0)
end if
else
toppic = nopic
end if
end function

code1 = "<P class=xpic align=center>wwwwwwwwww<img alt="""" src=""/UploadFile/201074235131540.jpg""><BR>[这里填写图片介绍]</P>"
pic = toppic(code1,"html","nopic.gif")

大家帮我看看现在显示
nopic.gif
应该是显示/UploadFile/201074235131540.jpg
楼下的不能用啊。你帮我测试下麻烦了
展开
 我来答
nnigou
2010-07-05 · TA获得超过983个赞
知道小有建树答主
回答量:1580
采纳率:0%
帮助的人:1586万
展开全部
<img.*?src\s*?\=\s*?\u0022*?([^\u0022\>]+)

正则换成这个

if leixing = "html" then
toppic = matches(0).submatches(3)
else
toppic = matches(0).submatches(0)
end if
这个判断换成只要 toppic = matches(0).submatches(0)
就可以
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式