Android(安卓)校验email是否合法实现代码
16lz
2021-01-25
Android 校验email是否合法
这个其实跟JAVA中是一样的。例子:
String regEx = "^(([\\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 void btnValidateEmailAddress(View v) { strEmailAddress = editTextEmail.getText().toString().trim(); Matcher matcherObj = Pattern.compile(regEx).matcher(strEmailAddress); if (matcherObj.matches()) { Toast.makeText(v.getContext(), strEmailAddress+" is valid", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(v.getContext(), strEmailAddress+" is InValid", Toast.LENGTH_SHORT).show(); } }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
更多相关文章
- android 个人论坛地址
- Android通用Adapter使用例子
- widget开发实例代码
- Android(安卓)配置 OpenCV2.3.1
- Eclipse如何打开Package Explorer
- C++调用Android函数弹出一个提示框中出现的问题总结
- android上怎样让一个Service开机自动启动
- [Android]错误: -source 1.7 中不支持 lambda 表达式 (请使用 -s
- android中TextView分段显示不同颜色,字体,时间