【问题标题】:Using regexp replace in JavaScript在 JavaScript 中使用正则表达式替换
【发布时间】:2019-01-05 01:02:34
【问题描述】:

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

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

【问题讨论】:

标签: javascript regex


【解决方案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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 2014-01-26
    • 2010-11-12
    • 2016-09-23
    • 1970-01-01
    • 2012-05-08
    • 2017-10-29
    相关资源
    最近更新 更多