Example usage for java.util.regex Matcher matches

List of usage examples for java.util.regex Matcher matches

Introduction

In this page you can find the example usage for java.util.regex Matcher matches.

Prototype

public boolean matches() 

Source Link

Document

Attempts to match the entire region against the pattern.

Usage

From source file:Main.java

public static boolean isHttp(String url) {
    Pattern patt = Pattern.compile(regex);
    Matcher matcher = patt.matcher(url);
    return matcher.matches();
}

From source file:com.cy.common.util.ValidateUtil.java

/**
 * //from  w  w w .  j a v  a  2  s  .  com
 * @param mail ?
 * @return 
 */
public static boolean isMail(String mail) {
    if (StringUtils.isBlank(mail)) {
        return false;
    }
    Pattern mailRegx = Pattern
            .compile("^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,4}$");
    Matcher match = mailRegx.matcher(mail);
    return match.matches();
}

From source file:Main.java

public static boolean isPasswordValid(String password) {

    final String PASSWORD_PATTERN = "(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{8,}$";

    Pattern pattern = Pattern.compile(PASSWORD_PATTERN);
    Matcher matcher = pattern.matcher(password);
    return matcher.matches();
}

From source file:Main.java

public static boolean isNumeric(String str) {
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (!isNum.matches()) {
        return false;
    }//from w ww.  ja va2  s .co m
    return true;
}

From source file:Main.java

public static boolean isZeroFirst(String number) {
    Matcher match = PATTERN_ZERO_FIRST.matcher(number);
    return match.matches();
}

From source file:Main.java

public static boolean isNumeric(String string) {
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(string.trim());
    if (!isNum.matches()) {
        return false;
    }//from  www .j a  va 2s.c  o  m
    return true;
}

From source file:Main.java

public static boolean isFixPhone(String number) {
    Matcher match = PATTERN_FIXEDPHONE.matcher(number);
    return match.matches();
}

From source file:Main.java

public static boolean isMobile(String num) {
    boolean isValid = false;
    String expre = "(^(13|15|18|14)[0-9]{9}$)";
    // String expre = "^\\(?(\\d{3})\\)?[-]?(\\d{3})[-]?(\\d{5})$";
    // CharSequence inputStr = num;
    Pattern pattern = Pattern.compile(expre);
    Matcher matcher = pattern.matcher(num);
    if (matcher.matches()) {
        isValid = true;//from ww w.ja v  a 2  s.c om
    }
    return isValid;
}

From source file:Main.java

public static boolean isPhone(String num) {
    boolean isValid = false;
    // String expre = "^\\(?(\\d{3})\\)?[-]?(\\d{3})[-]?(\\d{5})$";
    String expre = "((^(13|15|18|14)[0-9]{9}$)|(^0[0-9]{1}\\d{1}[-]?\\d{8}$)|(^0[0-9]{1}\\d{2}[-]?\\d{7,8}$)|(^0[0-9]{1}\\d{1}[-]?\\d{8}-(\\d{1,4})$)|(^0[0-9]{1}\\d{2}[-]?\\d{7,8}-(\\d{1,4})$))";
    // CharSequence inputStr = num;
    Pattern pattern = Pattern.compile(expre);
    Matcher matcher = pattern.matcher(num);
    if (matcher.matches()) {
        isValid = true;/*w  ww .  j  a  v a 2 s  . c  om*/
    }
    return isValid;
}

From source file:Main.java

/**
 * (phoneNum is null return false)//from   ww w. j a v a  2s . co  m
 * yes return true; no return false;
 * @param phoneNum
 * @return boolean
 */
public static boolean isMobile(String phoneNum) {
    if (phoneNum != null) {
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$");
        Matcher m = p.matcher(phoneNum);
        return m.matches();
    } else {
        return false;
    }
}