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 MatchPhone(String name) {
    Pattern p = Pattern.compile("^((1[3,7][0-9])|(15[^4,\\D])|(18[0-3,5-9])|(14[5,7]))\\d{8}$");
    Matcher m = p.matcher(name);
    return m.matches();
}

From source file:Main.java

public static boolean isEmail(String str) {
    Pattern p1 = Pattern.compile("\\w+@(\\w+.)+[a-z]{2,3}");
    Matcher m = p1.matcher(str);
    return m.matches();
}

From source file:Main.java

public static boolean isSpecial(String str) {
    String regex = "[^~{}|\"#]{1,}";
    Pattern p = Pattern.compile(regex);
    Matcher m = p.matcher(str);
    return m.matches();
}

From source file:Main.java

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

From source file:Main.java

public static boolean checkPhone_2(String phone) {
    Pattern p = Pattern.compile("^1\\d{10}$");
    Matcher m = p.matcher(phone);
    return m.matches();
}

From source file:Main.java

public static boolean validEmail(String email) {
    Pattern p = Pattern.compile("^[a-zA-Z0-9][a-zA-Z0-9-_.]+?@([a-zA-Z0-9]+(?:\\.[a-zA-Z0-9-_]+){1,})$");
    Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

public static boolean checkIDCard(String idCard) {
    Pattern p = Pattern.compile("^(\\d{15}|\\d{17}[\\dxX])$");
    Matcher m = p.matcher(idCard);
    return m.matches();
}

From source file:Main.java

public static boolean isEmail(String email) {
    String str = "^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

public static boolean isZipCode(String zipcode) {
    Pattern p = Pattern.compile("[1-9]\\d{5}(?!\\d)");
    Matcher m = p.matcher(zipcode);
    return m.matches();
}

From source file:Main.java

public static boolean isChinaPhoneLegal(String str) throws PatternSyntaxException {
    String regExp = "^((13[0-9])|(15[^4])|(18[0,2,3,5-9])|(17[0-8])|(147))\\d{8}$";
    Pattern p = Pattern.compile(regExp);
    Matcher m = p.matcher(str);
    return m.matches();
}