+ 1

Last test case gets failed

Password validation (code coach) import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String pass = sc.nextLine(); if(pass.matches("(.*)[0-9]{2,}(.*)")&& pass.matches("(.*)[!@#$%&*]{2,}(.*)")&& pass.length()>=7) System.out.println("Strong"); else System.out.println("Weak"); } }

19th Oct 2020, 7:40 AM
Vignesh
Vignesh - avatar
5 Answers
+ 3
Just remove the two {2,}
19th Oct 2020, 8:06 AM
Mariano Fregosi
Mariano Fregosi - avatar
+ 3
To be honest I think it is a problem with the last case; your code is fine, because removing the regex {2,} generates false positives with a single special character / number as you say đŸ€”
20th Oct 2020, 10:27 AM
Mariano Fregosi
Mariano Fregosi - avatar
+ 1
Thanks Mariano it works!!
20th Oct 2020, 7:27 AM
Vignesh
Vignesh - avatar
0
Any corrections??
19th Oct 2020, 8:00 AM
Vignesh
Vignesh - avatar
0
What makes the difference their as the problem itself requires atleast 2 numerals and 2 spl characters Mariano
20th Oct 2020, 7:29 AM
Vignesh
Vignesh - avatar