List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean hasSpecialCharExceptSpace(String x) { Pattern p = Pattern.compile("[^a-zA-Z0-9 ]"); return p.matcher(x).find(); }
From source file:Main.java
public static boolean isPostCode(String postcode) { Pattern p = Pattern.compile("\\p{Digit}{6}"); boolean isExist = false; if (p.matcher(postcode).matches()) isExist = true;//from w w w. ja v a 2s. com return isExist; }
From source file:Main.java
public static boolean isNumeric(CharSequence str) { Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(str).matches(); }
From source file:Main.java
public static boolean isPhoneNumber(String phone) { Pattern pattern = Pattern.compile("1[0-9]{10}"); return ((phone != null) && pattern.matcher(phone).matches()); }
From source file:Main.java
public static boolean checkPassword(String password) { Pattern p = Pattern.compile("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$"); if (p.matcher(password).matches()) { return true; } else {//w w w . j a v a 2 s . c om return false; } }
From source file:Main.java
public static boolean isNumber(String str) { Pattern pattern = Pattern.compile("[0-9]*"); java.util.regex.Matcher match = pattern.matcher(str); if (match.matches() == false) { return false; } else {/*from w w w . ja va 2 s . co m*/ return true; } }
From source file:Main.java
public static boolean checkIncludeChinese(String chinese) { Pattern regex = Pattern.compile("[\u4e00-\u9fa5]"); return regex.matcher(chinese).find(); }
From source file:Main.java
public static boolean isValidateWxId(String s) { boolean flag; if (Pattern.compile("[\u4E00-\u9FA5]").matcher(s).find()) flag = false;//from w w w . j a v a2 s . c o m else flag = true; return flag; }
From source file:Main.java
public static Matcher sharp2sharp(String str) { return Pattern.compile("(#[^#]+?#)").matcher(str); }
From source file:Main.java
public static boolean isQQ(String qq) { Pattern p = Pattern.compile("^[0-9]{4,11}$"); Matcher m = p.matcher(qq);//from w w w . j a v a2s.c o m return m.matches(); }