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 checkPhoneNum(String userPhone) {
    String regExp = "^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(19[0-9])|(18[0-9]))\\d{8}$";
    Pattern p = Pattern.compile(regExp);
    Matcher m = p.matcher(userPhone);
    return m.matches();
}

From source file:Main.java

public static boolean isMobileNO(String mobiles) {
    if (mobiles == null) {
        return false;
    }/*from w w  w  .j a  v a2  s .c o  m*/
    // Pattern p =
    // Pattern.compile("^((1[0-9][0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$");
    Pattern p = Pattern.compile("^(1)\\d{10}$");
    Matcher m = p.matcher(mobiles);
    return m.matches();
}

From source file:Main.java

public static boolean isMobilePhoneNumber(String phoneNumber) {
    //  /^0{0,1}(13[4-9]|15[7-9]|15[0-2]|18[7-8])[0-9]{8}$/; 
    String reg_VerCode = "^(13|14|15|18)[0-9]{9}$";

    Pattern p = Pattern.compile(reg_VerCode);
    Matcher m = p.matcher(phoneNumber);
    return m.matches();
}

From source file:Main.java

public static boolean isIDNumber(String strID) {
    Pattern pattern = Pattern.compile(
            "((11|12|13|14|15|21|22|23|31|32|33|34|35|36|37|41|42|43|44|45|46|50|51|52|53|54|61|62|63|64|65|71|81|82|91)\\d{4})((((19|20)(([02468][048])|([13579][26]))0229))|((20[0-9][0-9])|(19[0-9][0-9]))((((0[1-9])|(1[0-2]))((0[1-9])|(1\\d)|(2[0-8])))|((((0[1,3-9])|(1[0-2]))(29|30))|(((0[13578])|(1[02]))31))))((\\d{3}(x|X))|(\\d{4}))");
    Matcher m = pattern.matcher(strID);
    if (m.matches()) {
        return true;
    } else {/*from   ww  w.ja  v a2 s .  c o m*/
        return false;
    }
}

From source file:Main.java

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

From source file:Main.java

public static boolean checkMobilePhone(String mobilePhone) {
    String ps = "^(13|14|15|17|18)\\d{9}$";
    Pattern p = Pattern.compile(ps);
    Matcher m = p.matcher(mobilePhone);
    if (!m.matches()) {
        return false;
    }/*from   www  .j a va2 s.c om*/
    return true;
}

From source file:Main.java

public static boolean checkBalanceFormat(String balance) {
    String reg = "^(([1-9]\\d*)|0)(\\.\\d{1,2})?$";
    Pattern p = Pattern.compile(reg);
    Matcher matcher = p.matcher(balance);
    if (matcher.matches()) {
        return true;
    }/*w ww. j  av  a  2  s  . c o  m*/
    return false;
}

From source file:Main.java

public static boolean isValidEmail(String email) {
    java.util.regex.Pattern p = java.util.regex.Pattern.compile("\\S+@\\S+\\.\\S+");
    java.util.regex.Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

public static boolean CheckUserName(String name) {
    Pattern p = Pattern.compile("[0-9]*");
    Matcher m = p.matcher(name);
    if (m.matches()) {

    }/* ww  w . j ava  2s  .c om*/
    p = Pattern.compile("[a-zA-Z]");
    m = p.matcher(name);
    if (m.matches()) {

    }
    return true;
}

From source file:Main.java

private static boolean isEmail(String text) {
    String reg = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
    Pattern regex = Pattern.compile(reg);
    Matcher matcher = regex.matcher(text);
    return matcher.matches();

}