Regular expression that includes all keyboard characters except '~' and ','

前端 未结 6 1140
余生分开走
余生分开走 2021-02-19 20:03

How do I write a regular expression that includes all keyboard characters except \'~\' and \',\'?

6条回答
  •  情书的邮戳
    2021-02-19 20:53

    You didn't say what language/tool you're using, but in Java I would go with this regex:

    "[\\p{Print}&&[^~,]]"
    

    That's the intersection of two sets: all printing ASCII characters, and all characters that aren't a tilde or a comma.

提交回复
热议问题