替代全部:.replace(/#/g,"/") 替代第一个:.replace("#","/") var regS = new RegExp(keyWords, "g"); var reg = '<i style="color:red">' + keyWords + '</i>'; data = data.replace(regS, reg);