Assignment-2

This commit is contained in:
2026-04-23 18:51:17 +03:30
parent 1008068ada
commit d0a720bb11
+1 -1
View File
@@ -20,7 +20,7 @@ public class BonusExercises {
- Each segment (between dots) must follow same hyphen rules - Each segment (between dots) must follow same hyphen rules
*/ */
public boolean validateEmail(String email) { 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])?)*$"; // todo 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); Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(email); Matcher matcher = pattern.matcher(email);