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 isMatcherStr(String rex, String data) {
    Pattern pattern = Pattern.compile(rex);
    Matcher isNum = pattern.matcher(data);

    if (isNum.matches()) {
        return true;
    }/*from   w w  w  .j  a  v  a 2 s.  c o m*/
    return false;
}

From source file:Main.java

public static boolean checkEmail(String email) {

    Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$");
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean verifyEmail(String email) {
    Pattern pattern = Pattern.compile(
            "^([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})(\\]?)$");
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static Boolean validEmail(String email) {
    String regex = "^[a-z0-9A-Z_-]+@[a-z0-9A-Z_-]+(\\.[a-z0-9A-Z_-]+)+$";
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(email);
    return matcher.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);
    if (m.matches()) {
        return true;
    } else {//  w  w  w .  j a va 2 s  .c  o  m
        return false;
    }
}

From source file:Main.java

public static Boolean validPhone(String phone) {
    String regex = "^1[3-8]{1}[0-9]{9}$";
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(phone);
    return matcher.matches();
}

From source file:Main.java

public static boolean isCellphone(String str) {
    Pattern pattern = Pattern.compile("1[0-9]{10}");
    Matcher matcher = pattern.matcher(str);
    if (matcher.matches()) {
        return true;
    } else {//from   ww  w.  ja  v  a2 s . c o m
        return false;
    }
}

From source file:Main.java

public static boolean isValidEmailAddress(String email) {
    String ePattern = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
    java.util.regex.Pattern p = java.util.regex.Pattern.compile(ePattern);
    java.util.regex.Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

public static boolean isEmailAddress(String email) {
    Pattern pattern = Pattern
            .compile("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
    // .compile("^/w+([-.]/w+)*@/w+([-]/w+)*/.(/w+([-]/w+)*/.)*[a-z]{2,3}$");
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

private static boolean isNumeric(String str) {
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (isNum.matches()) {
        return true;
    } else {// w  w w. java2  s .  c  o  m
        return false;
    }
}