In PHP there is a function called
preg_match[
^] which returns
1
if a given string matches the provided pattern:
$email_string;
$simple_email_pattern = "/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/";
$match = preg_match($simple_email_pattern, $email_string);
if ($match === 1) {
}
For a better Regular Expression I would recommend taking a look at
this question[
^] on SO
In Java the String class offers a method called
matches[
^]:
String emailString = "test@test.test";
boolean emailIsValid = emailString.matches("^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$");