Does anyone know what the exact regular expression of androids patterns.EMAIL_ADDRESS uses?
I need to use the same pattern for PHP. Thank you.
Does anyone know what the exact regular expression of androids patterns.EMAIL_ADDRESS uses?
I need to use the same pattern for PHP. Thank you.
this is how PHP filter email
$Email = "dev@gmail.com";
if (filter_var($Email, FILTER_VALIDATE_EMAIL))
echo "Email Is Valid";
else
echo "Email Isn't Valid";
public boolean checkEmail(EditText editText) {
boolean emailIsValid = editText.getText().toString().matches("[^.]?([a-zA-Z0-9]+[._]?)*[-]?([a-zA-Z0-9]+[._]?)*[a-zA-Z0-9][@][a-z0-9]*[-]?[a-z0-9]*[.][a-z0-9]*[.]?[a-z0-9]*");
return !(android.util.Patterns.EMAIL_ADDRESS.matcher(editText.getText().toString()).matches()) || !emailIsValid;
}
if it returns true then it is not a valid email.
checkEmail method will return true, if email text is valid.
public final static Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile(
"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
+ "((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
+ "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
+ "([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
+ "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
+ "([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$");
public static boolean checkEmail(String email) {
return EMAIL_ADDRESS_PATTERN.matcher(email).matches();
}