var str = "de&hwje&bwej"; 例如我们要把str中的&全部替换成# var newStr = str.replace(/&/g,"#"); 输出newStr就是想要的结果: de#hwje#bwej