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 isMobileNO(String mobiles) {
    boolean flag = false;
    try {/*from   w  w w .  ja  v a 2 s .co m*/
        // 13********* ,15********,18*********
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\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 isNumeric(String str) {
    if (TextUtils.isEmpty(str)) {
        return false;
    }/*from  w ww . ja  v a  2  s .c  o m*/
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (!isNum.matches()) {
        return false;
    }
    return true;
}

From source file:Main.java

public static boolean isPhoneNumber(String number) {
    String regulation = "^((11[0-9])|(12[0-9])|(13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9])|)//d{8}$";
    Pattern pattern = Pattern.compile(regulation);
    Matcher matcher = pattern.matcher(number);
    if (matcher.matches()) {
        return true;
    }/*w  w w . jav a2  s.  c  om*/

    return false;
}

From source file:Main.java

public static boolean isMobileNum(String phoneNum) {
    boolean flag = false;
    try {/*from ww w  . j  a  v  a2s.c o  m*/
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
        Matcher m = p.matcher(phoneNum);
        flag = m.matches();
    } catch (Exception e) {
        flag = false;
    }
    return flag;
}

From source file:Main.java

public static boolean validateEmail(final String email) {

    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();
}

From source file:Main.java

public static boolean isUrlCorrect(String url) {
    if (url != null) {
        String check = "(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?";
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(url);
        return matcher.matches();
    }/*w  w  w  .  j a  v  a2 s  . c o m*/
    return false;
}

From source file:Main.java

public static boolean isNumeric(String str) {
    if (str == null || str.trim().equals("")) {
        return false;
    }/*from   w  ww .  j  a  v a2 s  .c om*/
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (isNum.matches()) {
        return true;
    } else {
        return false;
    }
}

From source file:TraverseDirectory.java

public static void traveseFile(String file) throws FileNotFoundException, IOException {
    BufferedReader buffer = new BufferedReader(new FileReader(file));
    Pattern p = Pattern.compile("^[7-9]\\d{9}");
    String read;//from w  w  w  .  j  a  v a2s. co  m
    while ((read = buffer.readLine()) != null) {
        Matcher r = p.matcher(read);
        if (r.matches()) {
            System.out.println(read);
        }
    }

}

From source file:Main.java

public static boolean isMobileNO(String mobiles) {

    Pattern pattern = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
    Matcher matcher = pattern.matcher(mobiles);

    return matcher.matches();

}

From source file:Main.java

public static final boolean checkPhone(String phone) {
    //Pattern pattern = Pattern.compile("^((13[0-9])|(15[0-9])|(18[0-9])|(17[0-9])|(147))\\d{8}$");
    Pattern pattern = Pattern.compile("^(1\\d{10})$");
    Matcher matcher = pattern.matcher(phone);

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