diff --git a/src/main/java/BonusExercises.java b/src/main/java/BonusExercises.java new file mode 100644 index 0000000..aa38149 --- /dev/null +++ b/src/main/java/BonusExercises.java @@ -0,0 +1,59 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class BonusExercises { + + /* + complete the method below, so it will validate an email address + */ + public boolean validateEmail(String email) { + String regex = ""; // todo + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(email); + + return matcher.matches(); + } + + /* + this method should find a date in string + note that it should be in british or american format + if there's no match for a date, return null + */ + public String findDate(String string) { + // todo + return null; + } + + /* + given a string, implement the method to detect all valid passwords + then, it should return the count of them + + a valid password has the following properties: + - at least 8 characters + - has to include at least one uppercase letter, and at least a lowercase + - at least one number and at least a special char "!@#$%^&*" + - has no white-space in it + */ + public int findValidPasswords(String string) { + // todo + return -1; + } + + /* + you should return a list of *words* which are palindromic + by word we mean at least 3 letters with no whitespace in it + + note: your implementation should be case-insensitive, e.g. Aba -> is palindrome + */ + public List findPalindromes(String string) { + List list = new ArrayList<>(); + // todo + return list; + } + + public static void main(String[] args) { + // you can test your code here + } +}