(Common API) regular expression-mail address verification

package cn.learn.demo01;

public class RegexDemo2 {
	public static void main(String[] args) {
		checkMail();
	}
	/*
	 *  检查邮件地址是否合法
	 *  规则:
	 *   [email protected]
	 *   [email protected]
	 *   [email protected]
	 *   [email protected]    
	 *   
	 *   @: 前  数字字母_ 个数不能少于1个
	 *   @: 后  数字字母     个数不能少于1个
	 *   .: 后面 字母 
	 *     
	 */
	public static void checkMail(){
		String email ="[email protected]";
		boolean b = email.matches("[a-zA-Z0-9_]+@[0-9a-z]+(\\.[a-z]+)+");
		System.out.println(b);
	}
}

 

Released 2417 original articles · won praise 62 · Views 200,000 +

Guess you like

Origin blog.csdn.net/Leon_Jinhai_Sun/article/details/105175591