📅  最后修改于: 2022-03-11 14:56:07.192000             🧑  作者: Mango
String validateEmail(String value) {
Pattern pattern =
r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]"
r"{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]"
r"{0,253}[a-zA-Z0-9])?)*$";
RegExp regex = new RegExp(pattern);
if (!regex.hasMatch(value) || value == null)
return 'Enter a valid email address';
else
return null;
}