Regex to remove all special characters from string?

前端 未结 9 1412
谎友^
谎友^ 2020-12-04 15:15

I\'m completely incapable of regular expressions, and so I need some help with a problem that I think would best be solved by using regular expressions.

I have list

9条回答
  •  情书的邮戳
    2020-12-04 16:03

    You can use:

    string regExp = "\\W";
    

    This is equivalent to Daniel's "[^a-zA-Z0-9]"

    \W matches any nonword character. Equivalent to the Unicode categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}].

提交回复
热议问题