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 isNumeric(String val) {
    Pattern pattern = Pattern.compile("^\\d+(\\.\\d+)?$");
    Matcher match = pattern.matcher(val);
    return match.matches();
}

From source file:Main.java

public static boolean isNumeric(String str) {
    Pattern pattern = Pattern.compile("^[0-9]+(.[0-9]*)?$");
    Matcher isNum = pattern.matcher(str);
    return isNum.matches();
}

From source file:Main.java

public static boolean isEmail(String email) {
    // String/* ww w . ja v  a  2  s . c  o  m*/
    // str="^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$";
    // String
    // str="^([a-z0-9A-Z]+[-|//.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?//.)+[a-zA-Z]{2,}$";
    String str = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

public static boolean isUrl(String url) {
    String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
    Pattern patt = Pattern.compile(regex);
    Matcher matcher = patt.matcher(url);
    return matcher.matches();
}

From source file:Main.java

public static boolean isAccountName(String name) {
    String check = "^[\\w\\*\\-\\.]{6,18}$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(name);
    return matcher.matches();
}

From source file:Main.java

public static boolean passwordFormat(String password) {
    Pattern pattern = Pattern.compile("^[\\@A-Za-z0-9\\!\\#\\$\\%\\^\\&\\*\\.\\~]{6,30}$");
    Matcher mc = pattern.matcher(password);
    return mc.matches();
}

From source file:Main.java

public static boolean checkIPAddress(String ip) {
    Pattern pattern = Pattern.compile(
            "\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
    Matcher matcher = pattern.matcher(ip);
    return matcher.matches();
}

From source file:Main.java

public static Boolean checkRegex(String regex, String str) {
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(str);
    return matcher.matches();
}

From source file:Main.java

public static boolean checkNumberPattern(String value, int intlen, int pointlen) {
    String ps = "^([0-9]{1," + intlen + "})$|^(-[0-9]{1," + intlen + "})$|^([0-9]{1," + intlen + "}.[0-9]{1,"
            + pointlen + "})$|^(-[0-9]{1," + intlen + "}.[0-9]{1," + pointlen + "})$";

    Pattern p = Pattern.compile(ps);
    Matcher m = p.matcher(value);
    if (!m.matches()) {
        return false;
    }/*from  w  w  w .  j  av  a2s.c o  m*/
    return true;
}

From source file:Main.java

public static boolean isNumeric(String str) {
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (!isNum.matches())
        return false;
    return true;// w  w w .jav  a 2s.  c  om
}