Regular expression include and exclude special characters

前端 未结 3 400
故里飘歌
故里飘歌 2020-12-30 01:22

I\'m finding a regular expression which adheres below rules.

Allowed Characters

Alphabet : a-z / A-Z
Numbers : 0-9
Special Characters : ~ @ # $ ^ &

3条回答
  •  爱一瞬间的悲伤
    2020-12-30 02:05

    You haven't actually asked a question, but assuming you have one, this could be your answer...

    Assuming all characters, except the "Special Characters" are allowed you can write

    String regex = "^[^<>'\"/;`%]*$";
    

提交回复
热议问题