PHP كود :
Function ValidatePassword(ByVal pwd As String,
Optional ByVal minLength As Integer = 8,
Optional ByVal numUpper As Integer = 2,
Optional ByVal numLower As Integer = 2,
Optional ByVal numNumbers As Integer = 2,
Optional ByVal numSpecial As Integer = 2) As Boolean
' Replace [A-Z] with \p{Lu}, to allow for Unicode uppercase letters.
Dim upper As New System.Text.RegularExpressions.Regex("[A-Z]")
Dim lower As New System.Text.RegularExpressions.Regex("[a-z]")
Dim number As New System.Text.RegularExpressions.Regex("[0-9]")
' Special is "none of the above".
Dim special As New System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]")
' Check the length.
If Len(pwd) < minLength Then Return False
' Check for minimum number of occurrences.
If upper.Matches(pwd).Count < numUpper Then Return False
If lower.Matches(pwd).Count < numLower Then Return False
If number.Matches(pwd).Count < numNumbers Then Return False
If special.Matches(pwd).Count < numSpecial Then Return False
' Passed all checks.
Return True
End Function
وهذا كود يمكن وضعه في اي حدث تريد للتحقق من كلمة المرور توافق المعاير التي وضعتها
كود :
Private Sub Button1_Click(ByVal Sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim MatchNumberPattern As String = "^.*(?=.{6,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$"
If TextBox2.Text.Trim <> "" Then
If Not Regex.IsMatch(TextBox2.Text, MatchNumberPattern) Then
MessageBox.Show("Invalid password !")
End If
End If
End Subوهي حسب الشروط التالي
(?=.{6,}) العدد 6 يدل على اقل عدد خانات مطلوب يمكنك تغييره لما تريد
(?=.*\d) التحقق من وجود رقم واحد
(?=.*[a-z]) التحقق من وجود حرف صغير
(?=.*[A-Z]) التحقق من وجود حرف كبير
(?=.*[@#$%^&+=]) التحقق من وجود رمز

