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 isIDcard(String idCard) {
    if (idCard != null) {
        Pattern p = Pattern.compile("(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)");
        Matcher m = p.matcher(idCard);
        return m.matches();
    } else {/*from   w  ww . j  av a2s .c  o  m*/
        return false;
    }
}

From source file:Main.java

public static boolean checkEmail(String email) {

    Pattern pattern = Pattern.compile("^\\w+([-.]\\w+)*@\\w+([-]\\w+)*\\.(\\w+([-]\\w+)*\\.)*[a-z]{2,3}$");
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean isLinkAvailable(String link) {
    Pattern pattern = Pattern.compile(
            "^(http://|https://)?((?:[A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\\.)+([A-Za-z]+)[/\\?\\:]?.*$",
            Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(link);
    return matcher.matches();
}

From source file:Main.java

public static boolean validateEmailAddress(String email) {
    Pattern pattern = Pattern.compile(EMAIL_REGEX, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean validateEmail(String email) {
    Pattern pattern = Pattern.compile(PATTERN_EMAIL);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public 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 . java 2s.  co m
        return false;
    }
}

From source file:Main.java

private static boolean match(String regex, String str) {
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(str);
    return matcher.matches();
}

From source file:Main.java

private static boolean match(String str, String rex) {
    if (null == str || str.trim().length() == 0) {
        return false;
    }/*  w  w w .  j  a v a  2  s .  c o  m*/
    Pattern pattern = Pattern.compile(rex);
    Matcher isNum = pattern.matcher(str);
    return isNum.matches();
}

From source file:Main.java

public static boolean isLong(String str) {
    if ("0".equals(str.trim())) {
        return true;
    }//from  w  w  w  . j a  va2  s .  co m
    Pattern pattern = Pattern.compile("^[^0]\\d*");
    Matcher isNum = pattern.matcher(str);
    return isNum.matches();
}

From source file:Main.java

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