日期:2014-05-16 浏览次数:20382 次
var s = '[2003][image/1.gif]'; var re = /\[[^\]]+([^\/]+\.gif)\]/; s = s.replace(re, '<img src="images/$1">'); alert(s)
------解决方案--------------------
var str = '[2003][image/1.gif][2003][image/1.png]';
var re = /\[([^\]]+\.gif)\]/g;
alert(str.replace(re,'<img src="$1">'))
------解决方案--------------------
var str = '[2003][image/1.gif][2003][image/1.png]'; var re = /\[(\w+/[^.]+\.gif)\]/gi; alert(str.replace(re,'<img src="$1">'))