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 validateNumber(String str) {
    Pattern pattern = Pattern.compile("[0-9]");
    Matcher matcher = pattern.matcher(str);

    return matcher.matches();
}

From source file:Main.java

public static boolean isHKPhoneLegal(String str) throws PatternSyntaxException {
    String regExp = "^(5|6|8|9)\\d{7}$";
    Pattern p = Pattern.compile(regExp);
    Matcher m = p.matcher(str);
    return m.matches();
}

From source file:Main.java

public static boolean isPrice(String params) {
    Pattern pattern = Pattern.compile("\\d{1,10}(\\.\\d{1,2})?$");
    Matcher matcher = pattern.matcher(params);
    return matcher.matches();
}

From source file:Main.java

public static boolean validateIp(String str) {
    Pattern pattern = Pattern.compile("[0-9],.");
    Matcher matcher = pattern.matcher(str);

    return matcher.matches();
}

From source file:Main.java

public static boolean isData(String number) {
    Pattern pattern = Pattern.compile("^[0-9]*$");
    Matcher m = pattern.matcher(number);
    if (m.matches()) {
        return true;
    } else {/*  ww w .  j a va 2s .com*/
        return false;
    }
}

From source file:Main.java

public static boolean isMobile(String mobile) {
    String check = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(mobile);
    return matcher.matches();
}

From source file:Main.java

public static boolean isValidPasswd(String passwd) {
    if (isEmpty(passwd)) {
        return false;
    }/*  w  ww .j a va  2  s .  c  o m*/

    Pattern p = Pattern.compile("[a-zA-Z0-9]{6,16}");
    Matcher m = p.matcher(passwd);
    return m.matches();
}

From source file:Main.java

public static boolean isIPAddress(String ipaddr) {
    boolean flag = false;
    Pattern pattern = Pattern.compile(
            "\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
    Matcher m = pattern.matcher(ipaddr);
    flag = m.matches();
    return flag;// w  w w  . j a v a2 s  .c  o m
}

From source file:Main.java

public static boolean verifyPassword(String pwd) {
    Pattern pattern = Pattern.compile("^[a-zA-Z0-9]{6,16}$");
    Matcher matcher = pattern.matcher(pwd);
    return matcher.matches();

}

From source file:Main.java

public static boolean isMobilePhone(String phone) {
    Pattern pattern = Pattern.compile("^((13[0-9])|(14[5,7])|(15[^4,\\D])|(17[6-8])|(18[0-9]))\\d{8}$");
    Matcher matcher = pattern.matcher(phone);
    return matcher.matches();
}