使用replaceAll替换所有字符串,例如
let result = "1 abc 2 abc 3".replaceAll("abc", "xyz"); // `result` is "1 xyz 2 xyz 3"
或者使用正则
var find = 'abc'; var re = new RegExp(find, 'g'); str = str.replace(re, '');
使用replaceAll替换所有字符串,例如
let result = "1 abc 2 abc 3".replaceAll("abc", "xyz"); // `result` is "1 xyz 2 xyz 3"
或者使用正则
var find = 'abc'; var re = new RegExp(find, 'g'); str = str.replace(re, '');