Validation of a Password - Python

前端 未结 11 1998
自闭症患者
自闭症患者 2020-11-27 08:20

So I have to create code that validate whether a password:

  • Is at least 8 characters long
  • Contains at least 1 number
  • Contains at least 1
11条回答
  •  时光说笑
    2020-11-27 08:29

    r_p = re.compile('^(?=\S{6,20}$)(?=.*?\d)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[^A-Za-z\s0-9])')
    

    this code will validate your password with :

    1. min length is 6 and max length is 20
    2. at least include a digit number,
    3. at least a upcase and a lowcase letter
    4. at least a special characters

提交回复
热议问题