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 isPasswordValid(String password) {
    if (isEmpty(password)) {
        return false;
    }/*from   w  ww  .  j  a v  a 2 s.  c om*/
    String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$";
    Pattern p = Pattern.compile(regex);
    Matcher matcher = p.matcher(password);
    return matcher.matches();
}

From source file:Main.java

public static boolean emailFormats(String email) {
    if (email == null)
        return false;
    String regular = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$";
    Pattern pattern = Pattern.compile(regular);
    Matcher matcher = pattern.matcher(email);
    if (!matcher.matches()) {
        return false;
    }/*from w w  w  . java 2 s .c  om*/
    return true;
}

From source file:Main.java

public static boolean isWord(String str) {
    Pattern pattern = Pattern.compile("^[A-Za-z]+$");
    Matcher isNum = pattern.matcher(str);
    if (!isNum.matches()) {
        return false;
    } else {/*from w w w . ja  va2 s. co  m*/
        return true;
    }
}

From source file:Main.java

public static boolean isFloat(String str) {
    if (isLong(str)) {
        return true;
    }//from  w  w  w . j  av a 2s. c  o m
    Pattern pattern = Pattern.compile("\\d*\\.{1}\\d+");
    Matcher isNum = pattern.matcher(str);
    return isNum.matches();
}

From source file:Main.java

public static boolean isDeletePng(EditText input, int cursor) {
    String st = "[p/_000.png]";
    String content = input.getText().toString().substring(0, cursor);
    if (content.length() >= st.length()) {
        String checkStr = content.substring(content.length() - st.length(), content.length());
        String regex = "\\[[^\\]]+\\]";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(checkStr);
        return m.matches();
    }//from  ww w .  j  a  va  2  s .  c  o  m
    return false;
}

From source file:Main.java

public static boolean isEmail(String email) {
    if (TextUtils.isEmpty(email)) {
        return false;
    }// www.  j a  va2 s  .c  o m
    String reg = "^[0-9a-z_-][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}\\.){1,4}[a-z]{2,4}$";
    Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean isNumber(String str) {
    if (isLong(str)) {
        return true;
    }/*w  w w. j  av  a2 s.co  m*/
    Pattern pattern = Pattern.compile("(-)?(\\d*)\\.{0,1}(\\d*)");
    Matcher isNum = pattern.matcher(str);
    return isNum.matches();
}

From source file:Main.java

public static boolean checkEmailFormat(String email) {
    if (TextUtils.isEmpty(email)) {
        return false;
    }// w  ww  .  j  av a  2  s .  c  o m
    String reg = "^[0-9a-z_-][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}\\.){1,4}[a-z]{2,4}$";
    Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean isValidEmail(CharSequence target) {
    if (target == null)
        return false;

    Pattern pattern = Pattern.compile(EMAIL_PATTERN, Pattern.CASE_INSENSITIVE);

    Matcher matcher = pattern.matcher(target);

    return matcher.matches();
}

From source file:Main.java

public static boolean isSpeciaCharacters(String str) {
    Pattern pattern = Pattern.compile("[/\\:*?<>|\"\n\t]");
    Matcher matcher = pattern.matcher(str);
    return matcher.matches();
}