日期:2014-05-16  浏览次数:20427 次

正则水平比较菜,再求一个正则,谢谢
aaaaaa <img   src= "images/[aa].gif "> fdsfdsa <img   src= "images/[bb].gif "> ccc

现在想把 <img   src= "images/[aa].gif "> 替换掉,只留[aa],如何做,谢谢

------解决方案--------------------
var b = 'aaaaaa <img src= "imaGes/[aa].gif "> fdsfdsa <img src= "images/[bb].gif "> ccc ';

alert(b.replace(/\ <img\ssrc\=\ "[a-z]+\/(\[.+?\])(.+?) "\> /ig, '$1 '));
------解决方案--------------------
<script>
var str= 'aaaaaa <img src= "images/[aa].gif "> fdsfdsa <img src= "images/[bb].gif "> ccc ';
re=/ <img.*(\[aa\]).*?> /ig;
str=str.replace(re, "[aa] ")
alert(str)
</script>


------解决方案--------------------
<script>
var str= 'aaaaaa <img src= "images/[aa].gif "> fdsfdsa <img src= "images/[bb].gif "> ccc ';
re=/ <img.*(\[aa\]).*?> /ig;
str=str.replace(re, "$1 ")
alert(str)
</script>