+ 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"); } }
5 odpowiedzi
+ 3
Just remove the two {2,}
+ 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 🤔
+ 1
Thanks Mariano it works!!
0
Any corrections??
0
What makes the difference their as the problem itself requires atleast 2 numerals and 2 spl characters Mariano