// 只替换第一个匹配
var str1 = " aa bb aa vv aa";
var str1Replace = str1.replace("aa","nn");
// 替换所有
var strdd = "#SPE# aa #SPE# ssddfsd #SPE#";
var sff = strdd.replace(new RegExp("#SPE#","gm"),"bbb");
// 只替换第一个匹配
var str1 = " aa bb aa vv aa";
var str1Replace = str1.replace("aa","nn");
// 替换所有
var strdd = "#SPE# aa #SPE# ssddfsd #SPE#";
var sff = strdd.replace(new RegExp("#SPE#","gm"),"bbb");