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 isChinaPhoneNumber(String phoneNum) {
    String PHONE_NUMBER_PATTERN = "^1[3578]\\d{9}";
    Pattern p = Pattern.compile(PHONE_NUMBER_PATTERN);
    Matcher m = p.matcher(phoneNum);
    return m.matches();
}

From source file:Main.java

public static boolean isInternationalPhoneNumber(String phoneNum) {
    String PHONE_NUMBER_PATTERN = "^\\d{1,4}-\\d{3,11}$";
    Pattern p = Pattern.compile(PHONE_NUMBER_PATTERN);
    Matcher m = p.matcher(phoneNum);
    return m.matches();
}

From source file:Main.java

public static boolean hasDigit2(String content) {
    boolean flag = false;
    Pattern p = Pattern.compile("[a-zA-Z0-9\\u4E00-\\u9FA5]+");
    Matcher m = p.matcher(content);
    if (m.matches()) {
        flag = true;/*w  w  w.j ava  2 s .c  o  m*/
    }
    return flag;
}

From source file:Main.java

public static boolean isEmail(String email) {
    String str = "^([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 p = Pattern.compile(str);
    Matcher m = p.matcher(email);

    return m.matches();
}

From source file:Main.java

public static boolean isEmail(String strEmail) {
    String EMAIL_PATTERN = "^[a-zA-Z0-9_-][\\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(EMAIL_PATTERN);
    Matcher m = p.matcher(strEmail);
    return m.matches();
}

From source file:Main.java

public static boolean isCode(String strCode) {
    String strPattern = "^[0-9]{6}";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strCode);
    return m.matches();
}

From source file:Main.java

public static boolean isValidPassword(String password) {
    String str = "^[0-9a-zA-Z]{6,20}$";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(password);
    return m.matches();
}

From source file:Main.java

public static boolean isPassCode(String strCode) {
    String strPattern = "^[0-9a-zA-Z@*%#()><!_~]{6,12}";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strCode);
    return m.matches();
}

From source file:Main.java

public static boolean isMobileNO(String mobiles) {
    Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[^4,\\D]))\\d{8}$");
    Matcher m = p.matcher(mobiles);

    return m.matches();
}

From source file:Main.java

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