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 checkEmail(String email) {
    //String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
    String check = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean validateIp(String aIp) {
    String IPADDRESS_PATTERN = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";

    Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);
    Matcher matcher = pattern.matcher(aIp);
    return matcher.matches();
}

From source file:Main.java

public static boolean isPhoneNum(String phonenum) {
    Pattern pattern = Pattern.compile("^(1[0-9])\\d{9}$");
    Matcher m = pattern.matcher(phonenum);
    if (m.matches()) {
        return true;
    } else {/*from ww w.  j a  v  a  2s .  co  m*/
        return false;
    }
}

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

    return m.matches();
}

From source file:Main.java

public static boolean verifyEmail(String email) {
    String regex = "^([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 pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean vertifyIsUrl(String str) {
    String regex = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?";
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(str);
    return matcher.matches();
}

From source file:Main.java

public static boolean validatestr(String str) {
    Pattern pattern = Pattern.compile("[0-9],.");
    Matcher matcher = pattern.matcher(str);

    return matcher.matches();
}

From source file:Main.java

public static boolean isEmail(String email) {

    String str = "^([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 p = Pattern.compile(str);
    Matcher m = p.matcher(email);
    return m.matches();

    /*/*from   w w w  . j a va2  s. co m*/
     * if (email != null && email.contains("@")) { return true; } else {
     * return false; }
     */
}

From source file:Main.java

public static boolean hasOnlyCharAndNumbers(String text) {
    String ePattern = "^[a-zA-Z0-9]+$";
    java.util.regex.Pattern p = java.util.regex.Pattern.compile(ePattern);
    java.util.regex.Matcher m = p.matcher(text);
    return m.matches();
}

From source file:Main.java

public static boolean isQQNumber(String qqNum) {
    if (qqNum != null) {
        Pattern p = Pattern.compile("^[1-9][0-9]{4,14}$");
        Matcher m = p.matcher(qqNum);
        return m.matches();
    } else {/*from  w w  w  .j  a v  a2 s.  c  om*/
        return false;
    }
}