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

前端 未结 9 876
花落未央
花落未央 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:19

    This is way way too late, but since there is no accepted answer I'd like to provide what I think is the simplest one: \D - matches all non digit characters.

    var x = "123 235-25%";
    x.replace(/\D/g, '');

    Results in x: "12323525"

    See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

提交回复
热议问题