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 isAlpha(String str) {
    String strPattern = "[a-zA-Z]+$";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(str);
    return m.matches();
}

From source file:Main.java

public static boolean isMobileNo(String mobiles) {
    Pattern p = Pattern.compile("^1[3|4|5|8][0-9]\\d{4,8}$");
    Matcher m = p.matcher(mobiles);
    return m.matches();
}

From source file:Main.java

public static boolean ifHasOnlyStr(String str) {
    String strPattern = "[a-zA-Z\u4e00-\u9fa5]+$";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(str);
    return m.matches();
}

From source file:Main.java

public static boolean checkPassword(String pwd) {
    String strPattern = "[A-Za-z0-9]{6,12}";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(pwd);
    return m.matches();
}

From source file:Main.java

public static boolean isPhoneHomeNum(String num) {
    Pattern p = Pattern.compile(
            "^(((13[0-9])|(15([0-3]|[5-9])|170)|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{8})$");
    Matcher m = p.matcher(num);
    return m.matches();
}

From source file:Main.java

public static boolean isOToN(String number) {
    Pattern p = Pattern.compile("\\d");
    Matcher m = p.matcher(number);
    return m.matches();
}

From source file:Main.java

public static boolean isLetter(String str) {
    String LETTER_PATTERN = "^\\w+$";
    Pattern p = Pattern.compile(LETTER_PATTERN);
    Matcher m = p.matcher(str);
    return m.matches();
}

From source file:Main.java

public static boolean isMobileNoAll(String mobiles) {
    Pattern p = Pattern.compile("^1[3|4|5|8][0-9]\\d{8}$");
    Matcher m = p.matcher(mobiles);
    return m.matches();
}

From source file:Main.java

public static boolean checkName(String name) {
    String str = "^([\\w]|[\\u4e00-\\u9fa5])+";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(name);
    return m.matches();
}

From source file:Main.java

public static boolean isAccountStandard(String uname) {
    Pattern p = Pattern.compile("[A-Za-z0-9_]+");
    Matcher m = p.matcher(uname);
    return m.matches();
}