G
Guest
Hello:
I am trying to use regular expressions to enforce the following requirements
on a password:
1. It has to be between 3-20 characters long.
2. Only a-z, A-Z, 0-9, +-_ are allowed.
3. At least one occurence of a lower case letter, a upper case letter and a
digit has to be used.
Two gentlemen guided me on this and based on their suggestion, I have the
following sub-routine:
Private sub test_password
Dim lsPassword As String
Dim lsPattern As String = "^([a-zA-Z0-9|\+|\-\(_)]{3,20})$"
lsPassword = "aa"
Dim mc As MatchCollection = Regex.Matches(lsPassword, lsPassword)
Dim m As Match
For Each m In mc
MsgBox(m.ToString)
Next
End Sub
I understand that mc collect how many matches it finds. So, in the above
example, I expect to get an array of 2.
But I see that Rules 1 and 3 are not enforced.
Can somebody suggest alternate ideas?
Thanks.
I am trying to use regular expressions to enforce the following requirements
on a password:
1. It has to be between 3-20 characters long.
2. Only a-z, A-Z, 0-9, +-_ are allowed.
3. At least one occurence of a lower case letter, a upper case letter and a
digit has to be used.
Two gentlemen guided me on this and based on their suggestion, I have the
following sub-routine:
Private sub test_password
Dim lsPassword As String
Dim lsPattern As String = "^([a-zA-Z0-9|\+|\-\(_)]{3,20})$"
lsPassword = "aa"
Dim mc As MatchCollection = Regex.Matches(lsPassword, lsPassword)
Dim m As Match
For Each m In mc
MsgBox(m.ToString)
Next
End Sub
I understand that mc collect how many matches it finds. So, in the above
example, I expect to get an array of 2.
But I see that Rules 1 and 3 are not enforced.
Can somebody suggest alternate ideas?
Thanks.