List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
private static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(str); return isNum.matches(); }
From source file:Main.java
public static boolean isEmailFormat(String email) { String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher("email"); boolean isMatched = matcher.matches(); return isMatched; }
From source file:Main.java
public static boolean isIdCard(String string) { String regExp = "\\d{17}[[0-9],0-9xX]"; Pattern pattern = Pattern.compile(regExp); Matcher matcher = pattern.matcher(string); return matcher.find();// boolean }
From source file:Main.java
private static String extractPattern(String string, String pattern, int group) { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(string); if (m.find()) { return m.group(group); } else {/*from w w w . ja va 2s .co m*/ return null; } }
From source file:Main.java
public static boolean checkValidPassword(String name) { Pattern p = Pattern.compile(pattern_pwd); Matcher matcher = p.matcher(name); return matcher.find(); }
From source file:Main.java
public static boolean isMobilePhone(String tel) { if (tel.contains(" ")) { tel = tel.replaceAll(" ", ""); }//from w w w . j a v a2s. c om if (tel.contains("-")) { tel = tel.replaceAll("-", ""); } Pattern p = Pattern.compile("(1)\\d{10}$"); return p.matcher(tel).matches(); }
From source file:Main.java
public static boolean isValidEmail(String s) { if (TextUtils.isEmpty(s)) { return false; }/*from ww w. ja va 2s . co m*/ String strPattern = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(s); return m.matches(); }
From source file:Main.java
public static boolean verifyEmail(String email) { String regex = "^([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 pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
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 boolean stringMatchesPattern(String s, String patt) { Pattern compiledPatt = Pattern.compile(patt); Matcher match = compiledPatt.matcher(s); return match.matches(); }