List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
public static boolean isEmail(String email) { String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; Pattern p = Pattern.compile(str); Matcher m = p.matcher(email); return m.matches(); }
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); return m.replaceAll(""); }
From source file:Main.java
public static boolean isPasswordStronger(String password) { String string = "^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])(?=.*[^A-Za-z0-9])).{6,}|(?:(?=.*[A-Z])(?=.*[a-z])|(?=.*[A-Z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*[0-9])|(?=.*[a-z])(?=.*[^A-Za-z0-9])|(?=.*[0-9])(?=.*[^A-Za-z0-9])|).{8,}"; Pattern p = Pattern.compile(string); Matcher m = p.matcher(password); return m.matches(); }
From source file:Main.java
public static boolean checkEmail(String email) { String regExp = "^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$"; Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(email); return m.matches(); }
From source file:Main.java
private static String getStringNum(String str) { String regEx = "[^0-9]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.replaceAll("").trim(); }
From source file:Main.java
public static String stringFilter(String str) throws PatternSyntaxException { String regEx = "[^\\u4E00-\\u9FA5]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.replaceAll("").trim(); }
From source file:Main.java
public static boolean stringMatchesAnyRegex(String s, Collection<Pattern> regexes) { if (s == null || regexes == null || regexes.isEmpty()) { return false; }/*from w ww . j a v a 2 s . c o m*/ for (Pattern regex : regexes) { if (regex.matcher(s).matches()) return true; } return false; }
From source file:Main.java
public static boolean matchRex(String src, String rex) { Pattern p = Pattern.compile(rex); Matcher m = p.matcher(src); return m.matches(); }
From source file:Main.java
public static boolean isChinaPhoneLegal(String str) throws PatternSyntaxException { String regExp = "^((13[0-9])|(15[^4])|(18[0,2,3,5-9])|(17[0-8])|(147))\\d{8}$"; Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(str); return m.matches(); }
From source file:Main.java
public static boolean checkPhoneNumber(String value) { String regExp = "^[1]([3][0-9]{1}|59|51|50|58|88|89|82)[0-9]{8}$"; Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(value); return m.find(); }