Softwaretechnik-II/testing/AufgabeEmailMatcher/EmailMatcher.java

17 lines
405 B
Java
Raw Normal View History

2024-10-30 19:29:50 +01:00
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class EmailMatcher {
2024-11-27 13:09:22 +01:00
// Regex für Emailadressen
static String emailRegex = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
2024-10-30 19:29:50 +01:00
2024-11-27 13:09:22 +01:00
static Pattern pattern = Pattern.compile(emailRegex);
static boolean isValidEmail(String email) {
2024-10-30 19:29:50 +01:00
Matcher matcher = pattern.matcher(email);
return matcher.matches();
2024-11-27 13:09:22 +01:00
}
2024-10-30 19:29:50 +01:00
}