正则表达式验证邮箱
具体操作:
package com.LG.正则表达式;
/*
*
*
* 1520025832 @ 163 . com
*
* \\w ----[a-zA-Z_0-9]
*
*
* [a-zA-Z_0-9]+@[a-zA-Z_0-9]+\\.[conm]{2,3}
*
* \\w+@\\w+\\.[conm]{2,3}
*
*
* 88555555@qq.com
*
* 867708234@qq.cn
*
*
*
*
*/
public class 正则验证邮箱格式 {
public static void main(String[] args) {
String str = "15210025832@163.com";
String regex = "\\w+@\\w+\\.[conm]{2,3}";
boolean flag = str.matches(regex);
if(flag){
System.out.println("格式正确");
}else{
System.out.println("格式不正确。。。");
}
}
/*
*
*
* 1520025832 @ 163 . com
*
* \\w ----[a-zA-Z_0-9]
*
*
* [a-zA-Z_0-9]+@[a-zA-Z_0-9]+\\.[conm]{2,3}
*
* \\w+@\\w+\\.[conm]{2,3}
*
*
* 88555555@qq.com
*
* 867708234@qq.cn
*
*
*
*
*/
public class 正则验证邮箱格式 {
public static void main(String[] args) {
String str = "15210025832@163.com";
String regex = "\\w+@\\w+\\.[conm]{2,3}";
boolean flag = str.matches(regex);
if(flag){
System.out.println("格式正确");
}else{
System.out.println("格式不正确。。。");
}
}
}