Assignment finished - Completed Main and Bonus exercises #1

Merged
peyman merged 10 commits from develop into main 2026-04-25 21:48:14 +00:00
Showing only changes of commit 42d26bcfa5 - Show all commits
+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;
} }
/* /*