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

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

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

6条回答
  •  萌比男神i
    2021-02-19 20:52

    Have you tried this?

    [^~,]
    

    Now to exclude characters not in keyboard, I believe you have to include them all.

    [a-zA-Z0-9\t\n ./<>?;:"'`!@#$%^&*()\[\]{}_+=|\\-]
    

    Which pretty much covers it (even though it looks like a crazy way to get things done). Maybe the problem definition can help you add more stuffs to exclude in the first list [^~,] than try to create a huge list of all keyboard chars.

提交回复
热议问题