HELP NEEDED WITH REGEX
-
I need to validate a password field with RegularExpression Validator. The validation logic is bit complex for me. Can anyone help me out with this Password must be a minimum of 8 characters and contain a combination of 3 of the following characters: - numbers - upper case letters - lower case letters - special character (*%$) I need this urgently. PLEASE SOMEONE PLS HELP. THANKS in advance
-
I need to validate a password field with RegularExpression Validator. The validation logic is bit complex for me. Can anyone help me out with this Password must be a minimum of 8 characters and contain a combination of 3 of the following characters: - numbers - upper case letters - lower case letters - special character (*%$) I need this urgently. PLEASE SOMEONE PLS HELP. THANKS in advance
A regular expression to do this (mostly because of the 3 out of 4 clause, would be incredibly long and would require intensive CPU time and quite a bit of memory. I would recommend that you instead create a custom validator that enumerates the characters and keeps a count, something like this:
' Assume password is in a string variable called "password"
If password.Length < 8 Then Return False
Dim i As Integer = 0
Dim b1 As Boolean
Dim b2 As Boolean
Dim b3 As Boolean
Dim b4 As Boolean
For Each c As Char In password
If Char.IsLetter(c) Then
If Char.IsLower(c) And Not b1 Then
b1 = True
i++
Else If Not b2
b2 = True
i++
End If
Else If Char.IsNumber(c) And Not b3 Then
b3 = True
i++
Else If (c = "*"c Or c = "%"c Or c = "$"c) And Not b4 Then
b4 = True
i++
End If
NextIf i >= 3 Then Return True
Else Return False-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----