一次 replace只能替换一个,例如: var str = 'test test test test' console.log(str.replace('test', 'tester')) 通过正则可以一下替换全部: someString = 'the cat looks like a cat'; anotherString = someString.replace(/cat/g, 'dog'); // anotherString now contains "the dog looks like a dog"     更多参考:http://www.tizag.com/javascriptT/javascript-string-replace… Read More