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

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

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

6条回答
  •  情话喂你
    2021-02-19 20:59

    I had to do this for regex to work:

    "[^~,][^~,]*" 
    

    because [^~,] negates ~ and ,

    [^~,]* means in zero or many copies of ~ and , (that is useless for our case)

    and by putting [^~,][^~,]* gets you to negate one or more copy of ~ or ,

提交回复
热议问题