+ 3

Struggling with Regex to Valid Password

The password should have atleast 2 numbers and 2 special characters... here with my regex any help will be appreciated "((?=.*\\d{2})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#

amp;*!%]{2}).{7,})”;

6th Jun 2020, 5:23 PM
DORIS NKUNA
DORIS NKUNA - avatar
3 Antworten
+ 2
This can be solved e.g.: string si = Console.ReadLine(); Regex r1 = new Regex(@"(?<psw>[^0-9]+)"); Regex r2 = new Regex(@"(?<psw>[^!\@\#\$%&\*]+)"); string s1 = r1.Replace(si,""); string s2 = r2.Replace(si,""); if(s1.Length>=2 && s2.Length>=2 && si.Length>=7){ Console.Write("Strong"); } else { Console.Write("Weak"); }
6th Jun 2020, 7:54 PM
JaScript
JaScript - avatar
0
(?=(.*\d){2,}) at least 2 digits
6th Jun 2020, 5:38 PM
Jay W
0
Thanks let me try your code
6th Jun 2020, 5:58 PM
DORIS NKUNA
DORIS NKUNA - avatar