1 Commits
Author SHA1 Message Date
Soroush 5994ce6fd0 Assignment-2 2026-05-06 12:26:31 +03:30
+1 -1
View File
@@ -20,7 +20,7 @@ public class BonusExercises {
- Each segment (between dots) must follow same hyphen rules
*/
public boolean validateEmail(String email) {
String regex = "^[^\\s.@]+(\\.[^\\s.@]+)*@[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$";
String regex = "^[^\\s.@]+(\\.[^\\s.@]+)*@[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(email);