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 verifyEmail(String email) {
    Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)"
            + "|(([a-zA-Z0-9\\-]+\\.)+))" + "([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean isValidMobilePhone(String s) {
    if (TextUtils.isEmpty(s)) {
        return false;
    }//from w w w. ja v  a 2 s. c  o  m
    Pattern pattern = Pattern.compile("1[0-9]{10}");
    Matcher matcher = pattern.matcher(s);
    return matcher.matches();
}

From source file:Main.java

public static String getProjectByUrl(String url) {
    Pattern pattern = Pattern.compile("https://(\\p{Ll}+).(.*)", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(url);
    if (!matcher.matches())
        throw new IllegalArgumentException("Regex fail. not matched. Url: " + url);

    return matcher.group(1);
}

From source file:Main.java

public static boolean isMobileNO(String mobileNo) {

    if (null == mobileNo || mobileNo.length() != 11)
        return false;

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

    return m.matches();
}

From source file:Main.java

public static boolean isNameValid(String name) {

    final String NAME_PATTERN = "[A-Z][a-z]+( [A-Z][a-z]+)?";
    Pattern pattern = Pattern.compile(NAME_PATTERN);
    Matcher matcher = pattern.matcher(name);
    return matcher.matches();
}

From source file:Main.java

private static boolean validateIP(final String ip) {

    Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);

    Matcher matcher = pattern.matcher(ip);
    return matcher.matches();
}

From source file:Main.java

public static boolean isEmail(String str) {
    String check = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(str);
    if (matcher.matches()) {
        return true;
    } else {/*from ww w .  j a v  a 2s  . c  om*/
        return false;
    }
}

From source file:Main.java

public static boolean isEmailValid(String email) {
    //TODO change for your own logic
    String ePattern = "^[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,}))$";
    java.util.regex.Pattern p = java.util.regex.Pattern.compile(ePattern);
    java.util.regex.Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

public static boolean checkEmail(Object strObj) {
    String str = strObj + "";
    String match = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
    Pattern pattern = Pattern.compile(match);
    Matcher matcher = pattern.matcher(str);
    return matcher.matches();
}

From source file:Main.java

/**********************************************************************/

public static boolean containsAtLeastOne(String src, String[] strings) {
    // TODO: regex isn't good enough - doesn't work with the start or end of line
    src = src.toLowerCase();/*  w ww . jav  a 2s . c o  m*/
    for (String s : strings) {
        Pattern p = Pattern.compile(".*[^a-z]" + s + "[^a-z].*");
        Matcher m = p.matcher(src);
        if (m.matches()) {
            return true;
        }
    }
    return false;
}