Regular Expression: Any character that is NOT a letter or number

前端 未结 9 859
花落未央
花落未央 2020-12-07 19:32

I\'m trying to figure out the regular expression that will match any character that is not a letter or a number. So characters such as (,,@,£,() etc ...

Once found I

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 20:11

    This regular expression matches anything that isn't a letter, digit, or an underscore (_) character.

    \W
    

    For example in JavaScript:

    "(,,@,£,() asdf 345345".replace(/\W/g, ' '); // Output: "          asdf 345345"
    

提交回复
热议问题