Java正則表達式校驗郵箱和手機號
來源:易賢網(wǎng) 閱讀:2210 次 日期:2014-09-05 10:29:16
溫馨提示:易賢網(wǎng)小編為您整理了“Java正則表達式校驗郵箱和手機號”,方便廣大網(wǎng)友查閱!

String check = "^([a-z0-9A-Z]+[-|.]?)+[a-z0-9A-Z]@

([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?.)+[a-zA-Z]{2,}$";

Pattern regex = Pattern.compile(check);

Matcher matcher = regex.matcher(email);

flag = matcher.matches();

}catch(Exception e){

flag = false;

}

return flag;

}

/**

* 驗證手機號碼

* @param mobiles

* @return [0-9]{5,9}

*/

public static boolean isMobileNO(String mobiles){

boolean flag = false;

try{

Pattern p = Pattern.compile("^((13[0-9])|(15[^4,D])|(18[0,5-9]))d{8}$");

Matcher m = p.matcher(mobiles);

flag = m.matches();

}catch(Exception e){

flag = false;

}

return flag;

}

public static boolean isNum(String number){

boolean flag = false;

try{

Pattern p = Pattern.compile("^[0-9]{5}$");

Matcher m = p.matcher(number);

flag = m.matches();

}catch(Exception e){

flag = false;

}

return flag;

}

}

更多信息請查看IT技術專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:Java正則表達式校驗郵箱和手機號
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)