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

前端 未结 30 3776
伪装坚强ぢ
伪装坚强ぢ 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:17

    What about considering the following regex solution:

    ^(?=.*[\w])(?=.*[\W])[\w\W]{8,}$

    Which validates the following:

    1. At least one lowercase
    2. At least one uppercase
    3. At least one digit
    4. At least one special character
    5. At least it should have 8 characters long.

    Check it out working at the following link https://regex101.com/r/qPmC06/4/

提交回复
热议问题