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 checkPhoneNumber(String phoneNumber) {
    Pattern pattern = Pattern.compile("^1[0-9]{10}$");
    Matcher matcher = pattern.matcher(phoneNumber);
    return matcher.matches();
}

From source file:Main.java

public static boolean isChinese(String str) {
    String check = "^[\u4e00-\u9fa5]+$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(str);
    if (matcher.matches()) {
        return true;
    } else {//from w w  w.  jav  a 2  s  .  com
        return false;
    }

}

From source file:Main.java

public static boolean isChineseMobileNO(String mobiles) {
    boolean flag = false;
    try {//from   www  .j  a v  a  2  s  .co m
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9])|(14[5,7]|(17[0,6,7,8])))\\d{8}$");
        Matcher m = p.matcher(mobiles);
        flag = m.matches();
    } catch (Exception e) {
        flag = false;
    }
    return flag;
}

From source file:Main.java

public static boolean isValidEmailAddress(String email) {
    String emailPattern = "^[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,}))$";
    Pattern p = Pattern.compile(emailPattern);
    Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

private static boolean isPhoneNumber(String number) {
    Pattern pattern = Pattern.compile("^(13[0-9]|15[0-9]|153|15[6-9]|180|18[23]|18[5-9])\\d{8}$");
    Matcher matcher = pattern.matcher(number);

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

From source file:Main.java

public static boolean isNumber(String number) {
    if (TextUtils.isEmpty(number))
        return false;
    else {//from  w  ww  .jav  a 2 s.c  om
        Pattern p = Pattern.compile("[0-9]*");
        Matcher m = p.matcher(number);
        if (m.matches())
            return true;
        else
            return false;
    }
}

From source file:Main.java

public static boolean checkPhone(String phone) {
    Pattern pattern = Pattern.compile("^(13[0-9]|15[0-9]|153|15[6-9]|180|18[23]|18[5-9])\\d{8}$");
    Matcher matcher = pattern.matcher(phone);

    if (matcher.matches()) {
        return true;
    }//from  www  .  ja  va 2  s . co m
    return false;
}

From source file:Main.java

public static boolean isEmailValid(String email) {
    if (isEmpty(email)) {
        return false;
    }//from   ww w  . j  a v a 2s  .c  om
    String regex = "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?";
    Pattern p = Pattern.compile(regex);
    Matcher matcher = p.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean isLetter(String s) {
    Pattern p = Pattern.compile("[^?!@#$%\\^&*(),<>;:]+");
    Matcher m = p.matcher(s);
    return m.matches();
}

From source file:Main.java

/**
 *
 * @return 'true' if seemingly valid e-mail address otherwise 'false'
 *//*from  w w  w . j a  v  a2  s . c o  m*/
public static boolean isValidEmail(String email) {
    final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
    Pattern pattern = Pattern.compile(EMAIL_PATTERN);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}