-1
Hello! I’m trying to validate an email provider in Java using regular expression, but I’m not getting a result. I declared the variable for regex as string, but the suggestion is to use Boolean, only Boolean doesn’t meet what I need. I need to validate only the provider name after @. Could anyone help? Thank you so much!
String email = [email protected];
String filter = email.matches("@[a-z0-9]+\\.");
if(filter == "provedor1") {
System.out.println("Usando o provedor1");
} else {
System.out.println("Usando o provedor2");
}
About using regex to validate emails, there are a few things here, here, here and here (this last link has some options at the end, just do not recommend the last regex).
– hkotsubo