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 isPhoneNum(String num) {
    Pattern pattern = Pattern.compile("^((13[0-9])|(15[0-9])|(18[0-9])|(147)|(17[0|6|7|8]))\\d{8}$");
    Matcher matcher = pattern.matcher(num);
    return matcher.matches();
}

From source file:Main.java

public static boolean isEmail(String email) {
    String check = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean isValidString(String str) {
    Pattern pattern = Pattern.compile("^(?:[\\u4e00-\\u9fa5]*\\w*\\s*)+$");
    Matcher matcher = pattern.matcher(str);
    return matcher.matches();
}

From source file:Main.java

public static boolean stringMatchesPattern(String s, String patt) {
    Pattern compiledPatt = Pattern.compile(patt);
    Matcher match = compiledPatt.matcher(s);
    return match.matches();
}

From source file:Main.java

public static boolean isEmail(String strEmail) {
    if (strEmail == null || strEmail.equals("")) {
        return false;
    }//from   w ww  . java2 s. c om
    String strPattern = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strEmail);
    return m.matches();
}

From source file:Main.java

public static boolean isDate(String strDate) {
    Pattern pattern = Pattern.compile(
            "^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s(((0?[0-9])|([1-2][0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$");
    Matcher m = pattern.matcher(strDate);
    return m.matches();
}

From source file:Main.java

public static boolean isEmail(String email) {
    if (email == null) {
        return false;
    }/*from  w  ww  .j ava  2  s  .  c o m*/
    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 isPwd(String str) {
    Pattern pattern = Pattern.compile("[A-Za-z0-9_]+");
    Matcher isPwd = pattern.matcher(str);
    if (!isPwd.matches()) {
        return false;
    }/*from ww w .  ja  v  a  2  s .  c o  m*/
    return true;
}

From source file:Main.java

public static boolean quanshiling(String number) {
    Pattern pattern = Pattern.compile("^0++$");
    Matcher m = pattern.matcher(number);
    if (m.matches()) {
        return false;
    } else {//from   w w w.  ja  v a2  s. c om
        return true;
    }
}

From source file:Main.java

public static boolean Passwrodvalidate(final String hex) {
    Pattern pattern = Pattern.compile(Passwrod_PATTERN);
    Matcher matcher = pattern.matcher(hex);
    return matcher.matches();
}