Private int checksecurity (string PWD) {return RegEx. Replace (PWD, "^ (? :( [A-Z]) | ([A-Z]) | ([0-9]) | (.)) {6 ,}| (.) + $ "," $1 $2 $3 $4 $5 "). length ;}
I have seen many methods on the Internet to verify the password strength, but I will not go into a long story.
Today, I have no intention of discovering a very good method, using regular expressions, and only one sentence is enough.
Here is a rough introduction:
Password characters include lowercase letters, uppercase letters, numbers, and symbols;
This regular expression will get five capture groups. The first four capture groups will tell us how many combinations the string contains (How many matches are returned to indicate how many combinations)
If the string is less than 6 digits, the fifth capture group is obtained. The length is 1 (that is, the intensity is 1). If no input is made, not even the capture group 5 (the intensity is 0)
Although it is a one-sentence function, it has learned a lot about regular expressions: scope, inclusion, length, capture, and replacement. Worship me!
However, the author seems to have said that it is still to be improved. I think it should be special characters, for example, the problem that full-angle characters cannot be correctly identified. Normal use is not affected.
Verify password strength with a regular expression