List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean hasDigit2(String content) { boolean flag = false; Pattern p = Pattern.compile("[a-zA-Z0-9\\u4E00-\\u9FA5]+"); Matcher m = p.matcher(content); if (m.matches()) { flag = true;//from ww w . java 2 s .com } return flag; }
From source file:Main.java
public static boolean isSpecial(String str) { String regex = "[^~{}|\"#]{1,}"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str);/*from w w w.java 2 s . co m*/ return m.matches(); }
From source file:Main.java
public static boolean isChineseChar(String str) { boolean temp = false; Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); Matcher m = p.matcher(str);//from w ww.ja v a 2s . c om if (m.find()) { temp = true; } return temp; }
From source file:Main.java
public static String getDynamicPassword(String str) { Pattern continuousNumberPattern = Pattern.compile("[0-9\\.]+"); Matcher m = continuousNumberPattern.matcher(str); String dynamicPassword = ""; while (m.find()) { if (m.group().length() == 4) { dynamicPassword = m.group(); }// w ww .j av a 2s . com } return dynamicPassword; }
From source file:Main.java
public static boolean isMobileNum(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(17[0-9])|(14[0-9])|(18[0-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); return !TextUtils.isEmpty(mobiles) && m.matches(); }
From source file:Main.java
public static String reSpecial(String str) { String regEx = "[/\\:*?<>|\"]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str);/*from w w w.j a v a 2s . co m*/ return m.replaceAll(""); }
From source file:Main.java
public static boolean isAlpha(String str) { String strPattern = "[a-zA-Z]+$"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(str);//from w ww . ja v a 2 s . c om return m.matches(); }
From source file:Main.java
public static String[] versionSplitting(String version, String regexVersionDelimiters) { Pattern pattern = Pattern.compile(regexVersionDelimiters); return pattern.split(version); }
From source file:Main.java
public static boolean checkphone(String phonenumber) { String phone = "\\d{11}"; Pattern p = Pattern.compile(phone); Matcher m = p.matcher(phonenumber); return m.matches(); }
From source file:Main.java
public static boolean isEmailOk(String s) { String regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; Pattern pattern = Pattern.compile(regex); return pattern.matcher(s).matches(); }