List of usage examples for java.util.regex Matcher matches
public boolean matches()
From source file:Main.java
public static boolean checkPhoneNumber(String number) { if (number.equals("") || number.length() != 11) { return false; }/*from w w w . j av a 2 s .co m*/ Pattern pattern = Pattern.compile("^((13[0-9])|(15[0-9])|(18[0-9])|(17[6-8])|(14[5,7]))\\d{8}$"); Matcher matcher = pattern.matcher(number); if (matcher.matches()) { return true; } else { return false; } }
From source file:Main.java
public static boolean isDate(String strDate) { Pattern pattern = Pattern .compile("^((\\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])))))?$"); Matcher m = pattern.matcher(strDate); return m.matches(); }
From source file:Main.java
public static boolean isEmailValid(String email) { if (email != null && !email.trim().isEmpty()) { Pattern pattern = Pattern.compile("^(.+\\..+)@futurice.com$"); Matcher matcher = pattern.matcher(email); return matcher.matches(); } else {/*from www. j av a 2 s . co m*/ return false; } }
From source file:Main.java
public static boolean MatchRegExp(String _str, String _regexp) { Pattern pattern = Pattern.compile(_regexp); Matcher matcher = pattern.matcher(_str); boolean matched = matcher.matches(); return matched; }
From source file:com.cy.common.util.ValidateUtil.java
/** * ????/*from www . j ava2 s.c o m*/ * @return false:?; true: * */ public static boolean validateTelePhone(String telephone) { if (StringUtils.isEmpty(telephone)) { return false; } Pattern pattern = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$"); Matcher macher = pattern.matcher(telephone); return macher.matches(); }
From source file:com.cy.common.util.ValidateUtil.java
/** * ? ???0571-88175786057188175786/*from ww w . j a v a 2s . c om*/ * @return false:?; true: * */ public static boolean validatePhone(String telephone) { if (StringUtils.isEmpty(telephone)) { return false; } Pattern pattern = Pattern.compile("^((0\\d{2,3}))(-{0,})(\\d{7,8})(-(\\d{3,}))?$"); Matcher macher = pattern.matcher(telephone); return macher.matches(); }
From source file:Main.java
public static boolean isPhone(String phoneNum) { try {/*from w w w . ja va 2s .c om*/ if (null != phoneNum) { Pattern p = Pattern.compile("1[358][0-9]{9}"); Matcher m = p.matcher(phoneNum); return m.matches(); } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static boolean isInt(Object srcStr) { // return null == srcStr || srcStr.equals("null"); if (srcStr == null) { return false; }/*www . j a v a 2s . co m*/ String s = srcStr.toString().replaceAll("(\\s)", ""); Pattern p = Pattern.compile("([-]?[\\d]+)"); Matcher m = p.matcher(s); return m.matches(); // return nvl(srcStr, "").trim().length() == 0 || nvl(srcStr, // "").equals("null"); }
From source file:Main.java
public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("^\\d+$"); Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { return false; }//from ww w.ja v a 2 s. c om return true; }
From source file:Main.java
public static boolean passwordFormat(String password) { if (password == null) return false; String regular = "^[a-zA-Z0-9_]{6,16}$"; Pattern pattern = Pattern.compile(regular); Matcher matcher = pattern.matcher(password); if (!matcher.matches()) { return false; }/*from www . j a v a2s . c om*/ return true; }