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
*/
public int findValidPasswords(String string) {
// todo
return -1;
String regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*]).{8,}$";
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;
}
/*