List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean isPassword(String str) { Pattern p = Pattern.compile("^[a-zA-Z0-9]{6,12}$"); Matcher m = p.matcher(str);//from w ww . j av a 2 s. c o m return m.matches(); }
From source file:Main.java
public static boolean isIDCard(String str) { Pattern p = Pattern.compile("\\d{15}|\\d{18}"); Matcher m = p.matcher(str);//from w w w.j a va 2s .co m return m.matches(); }
From source file:Main.java
public static boolean isZipCode(String zipcode) { Pattern p = Pattern.compile("[1-9]\\d{5}(?!\\d)"); Matcher m = p.matcher(zipcode); return m.matches(); }
From source file:Main.java
public static boolean isNull(String zipString) { String str = "^[^ ]{6,16}$"; return Pattern.compile(str).matcher(zipString).matches(); }
From source file:Main.java
public static String getEnglishNums(String num) { Pattern p = Pattern.compile("(?<=\\d)(?=(\\d\\d\\d)+$)"); Matcher m = p.matcher(num);// w ww . j a v a 2s. c o m return m.replaceAll(","); }
From source file:Main.java
public static boolean isChinese(String str) { Pattern p = Pattern.compile("^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$"); Matcher m = p.matcher(str);/*from ww w. j a v a 2s .com*/ return m.matches(); }
From source file:Main.java
public static boolean MatchPhone(String name) { Pattern p = Pattern.compile("^((1[3,7][0-9])|(15[^4,\\D])|(18[0-3,5-9])|(14[5,7]))\\d{8}$"); Matcher m = p.matcher(name);// www .ja v a 2s . com return m.matches(); }
From source file:Main.java
public static String u2s(String u) { Pattern pat = Pattern.compile("[\\\\U|\\\\u]([0-9a-fA-F]{4})"); Matcher mat = pat.matcher(u); while (mat.find()) { String HEX = mat.group(1); char v = (char) (Integer.parseInt(HEX.toUpperCase(), 16)); mat = pat.matcher(u = u.replace("\\" + mat.group(), "" + v)); }// w w w . j a v a 2s. com return u; }
From source file:Main.java
public static boolean isMobileNo(String mobiles) { Pattern p = Pattern.compile("^1[3|4|5|8][0-9]\\d{4,8}$"); Matcher m = p.matcher(mobiles); return m.matches(); }
From source file:Main.java
public static boolean isMobile(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); return m.matches(); }