
图像地址正则问题
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
楼下的不能用啊。你帮我测试下麻烦了 展开
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
楼下的不能用啊。你帮我测试下麻烦了 展开
1个回答
展开全部
<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)
就可以
正则换成这个
if leixing = "html" then
toppic = matches(0).submatches(3)
else
toppic = matches(0).submatches(0)
end if
这个判断换成只要 toppic = matches(0).submatches(0)
就可以
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询