Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters

前端 未结 30 3649
伪装坚强ぢ
伪装坚强ぢ 2020-11-21 04:28

I want a regular expression to check that:

A password contains at least eight characters, including at least one number and includes both lower and uppercase letter

30条回答
  •  别那么骄傲
    2020-11-21 05:01

    Minimum eight characters, at least one letter and one number:

    "^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"
    

    Minimum eight characters, at least one letter, one number and one special character:

    "^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$"
    

    Minimum eight characters, at least one uppercase letter, one lowercase letter and one number:

    "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"
    

    Minimum eight characters, at least one uppercase letter, one lowercase letter, one number and one special character:

    "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$"
    

    Minimum eight and maximum 10 characters, at least one uppercase letter, one lowercase letter, one number and one special character:

    "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,10}$"
    

提交回复
热议问题