List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean haveLetter(String password) { String str = ".*[a-zA-Z]+.*"; Pattern p = Pattern.compile(str); Matcher m = p.matcher(password); return m.matches(); }
From source file:Main.java
public static String url2Folder(String url) { Pattern p = Pattern.compile("android/(.*?)/"); Matcher m = p.matcher(url);/* w w w . j av a 2 s . co m*/ if (m.find()) { MatchResult mr = m.toMatchResult(); return mr.group(1); } else { return null; } }
From source file:Main.java
public static boolean isIPAddress(String ipaddr) { boolean flag = false; Pattern pattern = Pattern.compile( "\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b"); Matcher m = pattern.matcher(ipaddr); flag = m.matches();//from w w w .j a v a 2s . co m return flag; }
From source file:Main.java
public static boolean isChinese(String str) { String regEx = "[\\u4e00-\\u9fa5]+"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str);//from www.j av a2s . c o m return m.find(); }
From source file:Main.java
public static boolean isMobileNO(String cellphone) { Pattern p = Pattern.compile("^[1][34578]\\d{9}$"); Matcher m = p.matcher(cellphone); if (!TextUtils.isEmpty(cellphone)) { return m.matches(); }/*from www . j a v a 2 s .c o m*/ return false; }
From source file:Main.java
public static boolean isLetter(String string) { String regExp = "^[a-zA-Z]*$"; Pattern pattern = Pattern.compile(regExp); Matcher matcher = pattern.matcher(string); return matcher.find();// boolean }
From source file:Main.java
public static String replaceCN(String str) { String regEx = "[\\u4e00-\\u9fa5]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str);//w w w .ja v a 2s .co m return m.replaceAll(""); }
From source file:Main.java
public static boolean isPhone(String inputText) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(inputText); return m.matches(); }
From source file:Main.java
public static String strSpecial(String str) { String regEx = "[/\\:*?<>|\"\n\t]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str);/*from w w w. j av a 2s .co m*/ return m.replaceAll(""); }
From source file:Main.java
public static boolean isMobileNO(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(14[0-9])|(15[^4,\\D])|(17[0-9])|(18[0-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); return m.matches(); }