Implement findValidPasswords method

This commit is contained in:
2026-04-23 01:27:37 +03:30
parent 00c7229a9d
commit 42d26bcfa5
+12 -2
View File
@@ -62,8 +62,18 @@ public class BonusExercises {
- has no white-space in it - has no white-space in it
*/ */
public int findValidPasswords(String string) { public int findValidPasswords(String string) {
// todo String regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*]).{8,}$";
return -1; Pattern pattern = Pattern.compile(regex);
String[] parts = string.split("\\s+");
int counter = 0;
for(String part : parts){
Matcher matcher = pattern.matcher(part);
if(matcher.matches()){
counter++;
}
}
return counter;
} }
/* /*