List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean checkPassword(String password) { Pattern pattern = Pattern.compile(".*[a-zA-Z].*[0-9]|.*[0-9].*[a-zA-Z]"); //Pattern pattern = Pattern.compile("^[A-Za-z0-9]{6,20}$"); Matcher matcher = pattern.matcher(password); return matcher.matches(); }
From source file:Main.java
public static boolean isMobileNumber(String phoneNumber) { Pattern pattern = Pattern.compile("^(0|86|17951)?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[0-9])[0-9]{8}$"); Matcher matcher = pattern.matcher(phoneNumber); return matcher.matches(); }
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); if (m.matches()) { return true; } else {/*from w w w . ja va 2s. co m*/ return false; } }
From source file:Main.java
public static boolean isValidityEmailAddress(String address) { Pattern p = Pattern.compile("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.([a-zA-Z0-9_-])+)+$"); Matcher m = p.matcher(address); return m.matches(); }
From source file:Main.java
public static boolean isMobileNO(String mobiles) { Pattern pattern = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher matcher = pattern.matcher(mobiles); return matcher.matches(); }
From source file:Main.java
public static Boolean regex(String regex, String input) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(input); return matcher.find(); }
From source file:Main.java
public static String getNumberFromString(String text) { Pattern p = Pattern.compile("(\\d+)"); Matcher m = p.matcher(text);/* w w w. j a v a 2 s.co m*/ if (m.find()) { return (m.group(1)); } return ""; }
From source file:Main.java
public static boolean checkString(String username) { Pattern pattern = Pattern.compile("^[a-zA-Z0-9]+$"); Matcher matcher = pattern.matcher(username); return matcher.find(); }
From source file:Main.java
public static boolean isContainChinese(String str) { Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); Matcher m = p.matcher(str);//w ww .j a va 2s . c om if (m.find()) { return true; } return false; }
From source file:Main.java
public static boolean quanshiling(String number) { Pattern pattern = Pattern.compile("^0++$"); Matcher m = pattern.matcher(number); if (m.matches()) { return false; } else {// ww w . j av a2 s . c om return true; } }