======
有待改进,暂时先这样
<script type="text/javascript">
var str =
'<div><img src="/uploads/allimg/100429/1_100429134118_1.jpg" /><br />'+
'<img src="/uploads/allimg/100429/1_100429134118_2.jpg" /><br />'+
'<img src="/uploads/allimg/100429/1_100429134118_3.jpg" /></div>';
function getIMG(str) {
var reg = new RegExp("<img[^>]* src=\"([^\"]*)\"[^>]*>","gi");
var arrIMG = str.match(reg);
var newIMG = [];
for (var i in arrIMG) {
var t = arrIMG[i].replace(reg, "$1");
newIMG.push(t);
}
return newIMG;
}
var imgs = getIMG(str);
for (var i in imgs) {
alert(imgs[i]);
}
======好的方法
function getIMG(str) {
var reg = new RegExp("<img[^>]* src=\"([^\"]*)\"[^>]*>", "gi"),t,arrIMG=[];
while (t = reg.exec(str)) {
arrIMG.push(t[1]);
}
return arrIMG;
}
</script>