当前位置:网站首页>手机号、邮箱正则验证[通俗易懂]
手机号、邮箱正则验证[通俗易懂]
2022-06-28 09:22:00 【Java架构师必看】
大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说手机号、邮箱正则验证[通俗易懂],希望能够帮助大家进步!!!
private static String MOBILE_REGEX = "^(13[0-9]|15[012356789]|17[3678]|18[0-9]|14[57])[0-9]{8}$";
private static String EMAIL_REGEX = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
/** * 手机号正则验证 * @param str * @return */ public static boolean validateMobile(String str) {
Pattern pa = Pattern.compile(MOBILE_REGEX);
Matcher ma = pa.matcher(str);
while (ma.find()) {
return true;
}
return false;
}
/** * 邮箱正则验证 * @param str * @return */ public static boolean validateEmail(String str) {
Pattern pa = Pattern.compile(EMAIL_REGEX);
Matcher ma = pa.matcher(str);
while (ma.find()) {
return true;
}
return false;
}
边栏推荐
- [ybtoj advanced training guide] maximum separation [hash] [Floyd]
- Data visualization makes correlation analysis easier to use
- How to reduce the risk of project communication?
- "Jianzhi offer" -- Interview Question 4: finding two-dimensional arrays
- 静态代码块永远先执行? 格局小了!!!
- 分而治之之经典Hanoi
- Learn how Alibaba manages the data indicator system
- Expérience d'optimisation SQL: de 30248 secondes à 0001 secondes
- 满电出发加速品牌焕新,长安电动电气化产品吹响“集结号”
- Postman interface test
猜你喜欢
DBeaver安装与使用教程(超详细安装与使用教程)
RMAN backup message ora-19809 ora-19804
虚拟机14安装win7(图教程)
Data modeling based on wide table
Learn how Alibaba manages the data indicator system
Explain observer mode
Use of Jasper soft studio report tool and solution of thorny problems
Ingersoll Rand panel maintenance IR Ingersoll Rand microcomputer controller maintenance xe-145m
Chrome devtools
Calculation of stock purchase and sale expenses
随机推荐
Decision table method for basic content learning of software testing (2)
Check whether the table contains rows SQL Server 2005 - check whether a table contains rows or not SQL Server 2005
数据挖掘建模实战
Resource scheduling and task scheduling of spark
How to implement two factor authentication MFA based on RADIUS protocol?
This article explains in detail the difficult problems and solutions faced by 3D cameras
虛擬機14安裝win7(圖教程)
DEJA_VU3D - Cesium功能集 之 052-模拟卫星轨道(高空)效果
State machine program framework
Machine virtuelle 14 installer win7 (tutoriel)
Ingersoll Rand面板维修IR英格索兰微电脑控制器维修XE-145M
Basic content learning of software testing (I)
P2394 yyy loves Chemistry I
[big case] Xuecheng online website
I want to register my stock account online. How do I do it? Is online account opening safe?
Implementation of single sign on
Copy & Deepcopy
Ingersoll Rand panel maintenance IR Ingersoll Rand microcomputer controller maintenance xe-145m
Apache Doris becomes the top project of Apache
買賣股票費用計算