Regular expression include and exclude special characters

前端 未结 3 405
故里飘歌
故里飘歌 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:02

    [a-zA-Z0-9~@#\^\$&\*\(\)-_\+=\[\]\{\}\|\\,\.\?\s]*
    

    This would do the matching, if you only want to allow that just wrap it in ^$ or any other delimiters that you see appropriate, if you do this no specific disallow logic is needed.

提交回复
热议问题