1. 程式人生 > >Python 正則表示式驗證密碼完整性

Python 正則表示式驗證密碼完整性

Regular Expression

1. Length between 8 and 32 characters
^[\s\S]{8,32}$

2. ASCII visible and space characters only
Rule: match A-Z,0-9,a-z and ASCII punctualtion
      no control characters, line breaks, characters out of the ASCII talbe are allowed
^[\x20-\x7E]+$

3. One or more uppercase letters
[A-Z]+

4. One or more lowercase letters
[a-z]+

5. One or more numbers
[0-9]+

6. One or more special characters
[ !"#$%&'()*+,\-./:;<=>
[email protected]
[\\\]^_`{|}~] 7. Anything other than ASCII letters and numbers [^a-zA-Z0-9] 8. Disallow three or more sequential identical characters ([\s\S])\1\1 9. Mutil rules Length between 8 and 32 characters One or more upppercase letters One or more lowerercase letters One or more numbers ^(?=[\s\S]{8,32}$)(?=[\s\S]*[A-Z])(?=[\s\S]*[a-z])(?=[\s\S]*[0-9]).*