如何在JavaScript中使用replace regex去除句子中不是字母,数字或空格的所有内容?
var string = "here is a sentence with letters and numbers and symbols 123!@#";
答案 0 :(得分:1)
var string = "here is a sentence with letters and numbers and symbols 123!@#";
var x = string.replace(/[^a-zA-Z0-9 ]/g,'')
console.log(x)