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 validatePayment(String amount) {
    String regEx = "^[1-9][0-9]*$";
    Matcher matcherObj = Pattern.compile(regEx).matcher(amount);
    if (matcherObj.matches())
        return true;
    else// w ww.  ja  va 2 s.com
        return false;
}

From source file:Main.java

public static boolean shouldBeTranslated(String s) {
    if (s.isEmpty())
        return false;

    if (s.trim().isEmpty())
        return false;

    Matcher matcher = number_pattern.matcher(s);

    if (matcher.matches())
        return false;

    return true;//from   w w  w  .  j  av  a  2 s  . com
}

From source file:Main.java

public static boolean isEmail(String email) {
    if ((email == null) || (email.trim().equals(""))) {
        return false;
    }//from   w ww  .ja  va2  s .  c om
    String emailRegular = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
    Pattern regex = Pattern.compile(emailRegular);
    Matcher matcher = regex.matcher(email);
    boolean isMatched = matcher.matches();
    return isMatched;
}

From source file:Main.java

public static boolean isMobileNO(String mobiles) {
    Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
    Matcher m = p.matcher(mobiles);
    Log.i("BaseUtils-->isMobileNO-->", m.matches() + "");
    return m.matches();
}

From source file:Main.java

public static boolean isPhoneNumberValid(String phoneNumber) {

    boolean isValid = false;

    String expression = "((^(13|15|18)[0-9]{9}$)|(^0[1,2]\\d-?\\d{8}$)|(^0[3-9] \\d{2}-?\\d{7,8}$)|(^0[1,2]\\d-?\\d{8}-(\\d{1,4})$)|(^0[3-9]\\d{2}-? \\d{7,8}-(\\d{1,4})$))";

    Pattern pattern = Pattern.compile(expression);
    Matcher matcher = pattern.matcher(phoneNumber);

    if (matcher.matches()) {
        isValid = true;/*from   ww  w.ja  v a  2 s. c o  m*/
    }
    return isValid;
}

From source file:Main.java

public static boolean checkString(String string) {
    String check = "^[0-9A-Za-z_]{6,20}$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(string.trim());
    boolean isMatched = matcher.matches();
    return isMatched;
}

From source file:Main.java

public static Date parseDate(String dateString) {
    Matcher m = DATE_PATTERN.matcher(dateString.trim());
    if (!m.matches()) {
        throw new IllegalArgumentException("\"" + dateString + "\" must be in YYYY-MM-DD format.");
    }/*  w w  w .j a va  2  s.  c  o m*/
    Calendar c = Calendar.getInstance();
    c.set(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)) - 1, Integer.parseInt(m.group(3)));
    return c.getTime();
}

From source file:Main.java

public static boolean checkCharacter(String character) {
    boolean flag = false;
    try {// ww w  .  jav  a  2 s.c o m
        //String check = "[a-zA-Z0-9@.-]{6,20}";
        String check = "[1-9][0-9]{5,11}";
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(character);
        flag = matcher.matches();
    } catch (Exception e) {
        flag = false;
    }
    return flag;
}

From source file:Main.java

public static boolean isEmail(String email) {

    if (TextUtils.isEmpty(email))
        return false;

    String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";

    Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);

    if (matcher.matches())
        return true;
    else//from  ww w .  java 2 s . c o  m
        return false;

}

From source file:Main.java

public static final boolean isValidEmail(final String email) {
    boolean result = false;
    if (email != null) {
        // \\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*
        Pattern pattern = Pattern.compile("\\w+(\\.\\w+)*@\\w+(\\.\\w+)+");
        Matcher matcher = pattern.matcher(email.trim());
        result = matcher.matches();
    }//from  www  .  j a v  a 2  s  . c o  m
    return result;
}