How to create a regular expression for checking the password, which should consist of 0-9 az AZ and have at least one digit, one small and one big letter?
- 12-25 characters long - gtx nvd
- Why dictate to the user what password he should have? The minimum length of 12 is tin. Issue certificates instead of a password. - vp_arth
- Certificates are by itself) - gtx nvd
|
2 answers
Here is one of the variations of the English version of the stack ^(?=.*[az])(?=.*[AZ])(?=.*\d)[a-zA-Z\d]{12,25}$
(?=.*[az]) - small letter(?=.*[AZ]) - large(?=.*\d) - number[a-zA-Z\d] - everything else is letters and numbers{12,25} - from 12 to 25
|
^\S*(?=\S{12,25})(?=\S*[az])(?=\S*[AZ])(?=\S*[\d])\S*$ - (? = \ S {12,25}): sets a password limit of 12-25 characters
- (? = \ S * [az]): contains at least one small letter
- (? = \ S * [AZ]): contains at least one large letter
- (? = \ S * [\ d]): and at least one digit
If you understand English there is a good article and very interesting discussions about this, in fact, there was this regular program, it works well, I used it myself.
Source: https://www.zorched.net/2009/05/08/password-strength-validation-with-regular-expressions/
- What error message to display if the user suddenly enters a space in his password, or even two? And what does the number 25 really mean in the regular season? - vp_arth
- Any output, you need a regular checker to check if you want to output the user exactly what he entered wrong in the password, then you need to break the regular schedule into several and then you will know exactly what the reason is, 12-25 is the minimum and maximum password length - Yaroslav Molchan
- Don't
\S*at the beginning and end tell you that there is no maximum length here? Why should the space in the password be a mistake? - vp_arth - \ S * matches any non-whitespace character. You can also go to any service and check what is written here and how it works. - Yaroslav Molchan
- regex101.com/r/MjHwbp/1 - vp_arth
|