正则表达式提取图片地址

javascript 版

<script language="javascript">
var a
='<P><IMG src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_117025184198149.jpg" mce_src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_117025184198149.jpg"></P><P><IMG src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_1170251841100502.jpg" mce_src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_1170251841100502.jpg"></P>'
var b
=/<IMG src=\"([^\"]*?)\">/gi
var s=a.match(b)

 
for(var i= 0;i<s.length;i++)
{
alert(s[i]);
alert(RegExp.$
1)
}


 
</script>



--------------------------------------------------------------------------------



<script language="javascript">
var a
='<P><IMG src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_117025184198149.jpg" mce_src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_117025184198149.jpg"></P><P><IMG src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_1170251841100502.jpg" mce_src="http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_1170251841100502.jpg"></P>'
var b
=/<IMG src=\"([^\"]*?)\">/gi
var s=a.match(b)

 
for(var i= 0;i<s.length;i++)
{
alert(s[i]);
alert(s[i].replace(b,
"$1"))
}


 
</script>
posted @ 2009-11-12 17:19  与时俱进  阅读(4952)  评论(0编辑  收藏  举报
友情链接:同里老宅院民居客栈