List of usage examples for java.util.regex Matcher matches
public boolean matches()
From source file:Main.java
public static boolean isValidPassword(String password) { String PASSWORD_PATTERN = "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,20})"; Pattern pattern = Pattern.compile(PASSWORD_PATTERN); Matcher matcher = pattern.matcher(password); return matcher.matches(); }
From source file:Main.java
public static boolean isNumber(String number) { boolean flag = false; try {// w ww . j a va 2 s . c o m Pattern p = Pattern.compile("[0-9]+"); Matcher m = p.matcher(number); flag = m.matches(); } catch (Exception e) { flag = false; } return flag; }
From source file:Main.java
public static boolean isValidEmail(String email) { String ePattern = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$"; Pattern p = Pattern.compile(ePattern); java.util.regex.Matcher m = p.matcher(email); return m.matches(); }
From source file:Main.java
public static Boolean checkCellPhone(String cellPhone) { Pattern pattern = Pattern.compile("^((13[0-9])|(15[0-9])|(18[0-9]))\\d{8}$"); Matcher matcher = pattern.matcher(cellPhone); return matcher.matches(); }
From source file:Main.java
public static boolean isEmail(String email) { if (null == email || "".equals(email.trim())) return false; // String strPattern = // "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$"; Pattern p = Pattern.compile("^.*@{1}.+\\.{1}.*$"); Matcher m = p.matcher(email); return m.matches(); }
From source file:Main.java
public static boolean isMobileNum(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); System.out.println(m.matches() + "---"); return m.matches(); }
From source file:Main.java
public static boolean isValidEmail(String email) { String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; Pattern pattern = Pattern.compile(EMAIL_PATTERN); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
From source file:Main.java
public static boolean isValidUsername(String username) { String expression = "^[a-zA-Z0-9_]+$"; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(username); return matcher.matches(); }
From source file:Main.java
public static boolean isMobileNO(String mobiles) { boolean flag; try {//from ww w .java 2 s .c o m Pattern p = Pattern.compile("^((13[0-9])|(14[0-9])|(15[^4,\\D])|(18[0-9])|(17[0-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); flag = m.matches(); } catch (Exception e) { flag = false; } return flag; }
From source file:Main.java
public static boolean matching(String regex, String input) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(input); return matcher.matches(); }