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 isValidUserName(String username) {
    String str = "^[0-9a-zA-Z_]{6,12}$";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(username);
    return m.matches();
}

From source file:Main.java

public static boolean isWeb(String strWeb) {
    String strPattern = "(http://|ftp://|https://|www){0,1}[^\u4e00-\u9fa5\\s]*?\\.(com|net|cn|me|tw|fr)[^\u4e00-\u9fa5\\s]*";

    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strWeb);
    return m.matches();
}

From source file:Main.java

public static boolean isFixedPhone(String number) {
    Pattern p = Pattern.compile("^(([0\\+]\\d{2,3}-)?(0\\d{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$");
    Matcher match = p.matcher(number);
    return match.matches();
}

From source file:Main.java

public static boolean onlyWord(String content) {
    boolean flag = false;
    Pattern p = Pattern.compile("[a-zA-Z\\u4E00-\\u9FA5]+");
    Matcher m = p.matcher(content);
    if (m.matches()) {
        flag = true;//from  w w w.  j a va  2 s . co  m
    }
    return flag;
}

From source file:Main.java

public static boolean isPassword(String password) {

    Pattern p = Pattern.compile("^[\\dA-Za-z(!@#$%&)]{6,16}$");
    Matcher m = p.matcher(password);
    return m.matches();

}

From source file:Main.java

public static boolean checkEmail(String email) {
    String ps = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
    Pattern p = Pattern.compile(ps);
    Matcher m = p.matcher(email);
    if (!m.matches()) {
        return false;
    }/*from  www . j  a  v a  2 s .  c  om*/
    return true;
}

From source file:Main.java

public static boolean isEmail(String strEmail) {
    String strPattern = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strEmail);
    return m.matches();
}

From source file:Main.java

public static boolean patternMatch(String pattern, String str) {
    Pattern pat = Pattern.compile(pattern);
    Matcher matcher = pat.matcher(str);
    return matcher.matches();
}

From source file:Main.java

public static boolean isUserName(String userName) {
    String strPattern = "^([u4e00-u9fa5]|[ufe30-uffa0]|[a-zA-Z0-9_]){3,12}$";

    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(userName);
    return m.matches();
}

From source file:Main.java

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