boolean checkUserName(EditText editText) {
String userName = editText.getText().toString().trim();
errrToast(userName);
/*
* 正则表达式 测试 邮箱是否合法
*/
Pattern pattern = Pattern.compile(
"[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+",
Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(userName);
if (matcher.matches()) {
return true;
}
errrToast("邮箱格式输入错误");
return false;
}
原文:http://leerain.blog.51cto.com/8277864/1358450