How do I replace special characters with regex in javascript?

后端 未结 2 1799
醉酒成梦
醉酒成梦 2021-02-12 23:19

I need to replace special characters from a string, like this:

this.value = this.value.replace(/\\n/g,\'\');

Except for the regex part, I need

2条回答
  •  情话喂你
    2021-02-12 23:26

    Try:

    this.value = this.value.replace(/\w|-/g, '');
    

    Reference:

    • Regular Expressions, at the Mozilla Developer Network.

提交回复
热议问题