简体   繁体   中英

Using regexp replace in JavaScript

如何在JavaScript中使用replace regex去除句子中不是字母,数字或空格的所有内容?

var string = "here is a sentence with letters and numbers and symbols 123!@#";

 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) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM