日期:2014-05-16 浏览次数:20334 次
var s = [
'<div id="faces">',
'<img src="/public/img/face/1.gif" class="faceimg">',
'<img src="/public/img/face/2.gif" class="faceimg">',
'<img src="/public/img/face/3.gif" class="faceimg">',
'<img src="/public/img/face/4.gif" class="faceimg">',
'<img src="/public/img/face/5.gif" class="faceimg">',
'</div>'
].join(''),
reg = /<img src=.+?(\d+)\.gif[^>]+?>/g;
alert(s);
alert(s.replace(reg,'[em:$1]'));
var str="<img src=\"/public/img/face/2.gif\" class=\"faceimg\">sdfsdf<img src=\"/public/img/face/12.gif\" class=\"faceimg\">sdfwesdsdf<img src=\"/public/img/face/5.gif\" class=\"faceimg\">";
var reg=/<img src="\/public\/img\/face\/(\d+)\.gif" class="faceimg">/ig;
str=str.replace(reg,"[em:$1]");
alert(str);
var str = '<img src="/public/img/face/2.gif" class="faceimg"><img src="/public/img/face/3.gif" class="faceimg">';
str = str.replace(/<img src="\/public\/img\/face\/(.*?).gif" class="faceimg">/g,'[em:$1]');
console.log(str);