List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
public static boolean isPasswordValid(String password) { Pattern p = Pattern.compile(PASSWORD_REGULAR); Matcher m = p.matcher(password); 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); return m.matches(); }
From source file:Main.java
public static boolean isNumeric(String url) { Pattern patt = Pattern.compile("[0-9]*"); Matcher matcher = patt.matcher(url); return matcher.matches(); }
From source file:Main.java
public static boolean isCnEnNumCorrect(final String content) { String rex = "^[\u4e00-\u9fa5a-zA-Z0-9]+$"; Pattern pattern = Pattern.compile(rex); Matcher matcher = pattern.matcher(content); return matcher.matches(); }
From source file:Main.java
public static boolean isEmail(String strEmail) { if (strEmail == null || strEmail.equals("")) { return false; }/* w ww.ja v a 2 s .c o m*/ String strPattern = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(strEmail); 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 isNumeric(String str) { String regEx = "^-?[0-9]+$"; Pattern pat = Pattern.compile(regEx); Matcher mat = pat.matcher(str); if (mat.find()) { return true; } else {/*from w ww .java 2s . c o m*/ return false; } }
From source file:Main.java
public static boolean checkString(String string) { String check = "^[0-9A-Za-z_]{6,20}$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(string.trim()); boolean isMatched = matcher.matches(); return isMatched; }
From source file:Main.java
public static boolean checkEmail(String email) { //String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; String check = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(email); return matcher.matches(); }
From source file:Main.java
public static boolean isHanZi(String string) { String regExp = "^[\u4e00-\u9fa5]*$"; Pattern pattern = Pattern.compile(regExp); Matcher matcher = pattern.matcher(string); return matcher.find();// boolean }