Here you can find the source of isMobilesOrEmail(String str)
public static boolean isMobilesOrEmail(String str)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isMobilesOrEmail(String str) { if (isMobileNO(str) || isEmail(str)) { return true; }/* ww w .jav a 2 s .c om*/ return false; } public static boolean isMobileNO(String mobiles) { String regex = "^((13[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$"; return match(regex, mobiles); } public static boolean isEmail(String str) { String regex = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; return match(regex, str); } private static boolean match(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); } }