List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean isModleStr(String str, String regex) { if (str == null) { return false; } else {/* w w w .j av a 2s. c o m*/ return Pattern.compile(regex).matcher(str).matches(); } }
From source file:Main.java
public static boolean isMobileNO(String mobiles) { boolean flag; try {/*from w w w . ja v a2s. c o m*/ Pattern p = Pattern.compile("^((13[0-9])|(14[0-9])|(15[^4,\\D])|(18[0-9])|(17[0-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); flag = m.matches(); } catch (Exception e) { flag = false; } return flag; }
From source file:Main.java
public static boolean isID(String s) { String strPattern = "^\\d{15}|^\\d{17}([0-9]|X|x)$"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(s);/*ww w .ja va2 s .c o m*/ return m.matches(); }
From source file:Main.java
public static boolean isAccountName(String name) { String check = "^[\\w\\*\\-\\.]{6,18}$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(name); return matcher.matches(); }
From source file:Main.java
private static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(str); if (isNum.matches()) { return true; } else {/*from ww w .j a v a 2 s .c o m*/ return false; } }
From source file:Main.java
public static boolean isChineseBlank(String str) { String regex = "^[^\\s\u4e00-\u9fa5]{6,16}$"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str);//from w ww . jav a2 s . com return m.matches(); }
From source file:Main.java
public static boolean isValidEmail(String email) { boolean isValid = false; Pattern pattern = Pattern.compile( "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"); Matcher matcher = pattern.matcher(email); if (matcher.find()) { isValid = true;/*from w w w. j a v a 2 s . c om*/ } return isValid; }
From source file:Main.java
public static Boolean validPhone(String phone) { String regex = "^1[3-8]{1}[0-9]{9}$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(phone); return matcher.matches(); }
From source file:Main.java
public static boolean isValidPassword(String password) { String str = "^[0-9a-zA-Z]{6,20}$"; Pattern p = Pattern.compile(str); Matcher m = p.matcher(password); return m.matches(); }
From source file:Main.java
public static boolean isLetter(String str) { if (str == null || str.length() < 0) { return false; }/*from w w w. j ava 2 s . c om*/ Pattern pattern = Pattern.compile("[\\w\\.-_]*"); return pattern.matcher(str).matches(); }