List of usage examples for java.util.regex Matcher matches
public boolean matches()
From source file:Main.java
public static boolean checkIP(String IP) { if (null != IP) { String regex = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(IP); return matcher.matches(); }/* ww w. ja v a2 s . co m*/ return false; }
From source file:Main.java
public static boolean isPhoneNumber(String phoneNumber) { if (phoneNumber == null) return false; if (TextUtils.isEmpty(phoneNumber)) return false; Pattern pattern = Pattern.compile("^(86|\\+86)?[1][3,4,5,8][0-9]{9}$"); Matcher m = pattern.matcher(phoneNumber); return m.matches(); }
From source file:Main.java
public static Boolean isMobileNo(String str) { Boolean isMobileNo = false;//w w w .j a va 2 s .c om try { Pattern p = Pattern.compile("^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$"); Matcher m = p.matcher(str); isMobileNo = m.matches(); } catch (Exception e) { e.printStackTrace(); } return isMobileNo; }
From source file:Main.java
public static boolean isAvailableRealname(String realname) { String regEx = "^[\u4E00-\u9FA5]{2,4}+$"; Pattern pattern = Pattern.compile(regEx); Matcher matcher = pattern.matcher(realname); if (matcher.matches()) { return true; }/*from ww w. ja v a2 s .c om*/ return false; }
From source file:Main.java
/** * Validates email address/*from w w w . j a va2 s . com*/ * @param email The address to validate * @return True if it is valid. */ public static boolean validEmail(String email) { String regex = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
From source file:Main.java
private static boolean isDataFormat(String str) { boolean flag = false; // String/*from w w w. jav a 2 s . co m*/ // regxStr="[1-9][0-9]{3}-[0-1][0-2]-((0[1-9])|([12][0-9])|(3[01]))"; String regxStr = "^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s(((0?[0-9])|([1-2][0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$"; Pattern pattern1 = Pattern.compile(regxStr); Matcher isNo = pattern1.matcher(str); if (isNo.matches()) { flag = true; } return flag; }
From source file:Main.java
public static boolean isMobilePhoneNO(String mobiles) { boolean flag = false; try {/*from www.j a v a2s . c om*/ Pattern p = Pattern.compile("^(1[0-9]{10})$"); Matcher m = p.matcher(mobiles); flag = m.matches(); } catch (Exception e) { flag = false; e.printStackTrace(); } return flag; }
From source file:Main.java
public static boolean isEmail(String email) { if (TextUtils.isEmpty(email)) return false; Pattern pattern = Pattern .compile("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
From source file:Main.java
public static boolean isCorrectUserName(String str) { java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("[0-9a-zA-Z_]{6,60}"); java.util.regex.Matcher match = pattern.matcher(str); return match.matches(); }
From source file:Main.java
public static boolean isCorrectPwd(String str) { java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("[0-9a-zA-Z_]{6,18}"); java.util.regex.Matcher match = pattern.matcher(str); return match.matches(); }