Regex pattern including all special characters

后端 未结 18 1543
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 09:18

I want to write a simple regular expression to check if in given string exist any special character. My regex works but I don\'t know why it also includes all numbers, so wh

18条回答
  •  情深已故
    2020-12-02 09:35

    I have defined one pattern to look for any of the ASCII Special Characters ranging between 032 to 126 except the alpha-numeric. You may use something like the one below:

    To find any Special Character:

    [ -\/:-@\[-\`{-~]
    

    To find minimum of 1 and maximum of any count:

    (?=.*[ -\/:-@\[-\`{-~]{1,})
    

    These patterns have Special Characters ranging between 032 to 047, 058 to 064, 091 to 096, and 123 to 126.

提交回复
热议问题