Example usage for java.util.regex Pattern compile

List of usage examples for java.util.regex Pattern compile

Introduction

In this page you can find the example usage for java.util.regex Pattern compile.

Prototype

public static Pattern compile(String regex) 

Source Link

Document

Compiles the given regular expression into a pattern.

Usage

From source file:Main.java

public static boolean isNumer(String str) {
    Pattern pattern = Pattern.compile("[0-9]*");
    return pattern.matcher(str).matches();
}

From source file:Main.java

public static boolean isEmail(String str) {
    Pattern pattern = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
    return pattern.matcher(str).matches();
}

From source file:Main.java

public static boolean checkIP(String str) {
    Pattern pattern = Pattern.compile("^((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]"
            + "|[*])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]|[*])$");
    return pattern.matcher(str).matches();
}

From source file:Main.java

public static boolean isValidIPv4(String ipString) {
    Pattern p = Pattern.compile("^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$");
    return p.matcher(ipString).matches();
}

From source file:Main.java

public static boolean isMobilePhone(String paramString) {
    return Pattern.compile("^((13[0-9])|(14[0,9])|(15[\\d])|(17[0-9])|(18[0-9]))\\d{8}$").matcher(paramString)
            .matches();//from  ww w.  j a  v a2 s . com
}

From source file:Main.java

public static boolean checkingPhone(String phoneNum) {
    if (!Pattern.compile("(1(([35][0-9])|(47)|[8][01256789]))\\d{8}$").matcher(phoneNum).matches()) {
        return false;
    }//from   www .ja  va 2  s. c o m
    return true;
}

From source file:Main.java

public static boolean checkMobile(final String mobile) {
    return Pattern.compile("^13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|18[0-9]{9}$|17[0-9]{9}$").matcher(mobile)
            .matches();//from  w ww.ja v a  2s  .  co  m
}

From source file:Main.java

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

From source file:Main.java

public static boolean checkingEmail(String email) {
    if (!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(email).find()) {//  ww w  .j a va  2s  .  c  o  m
        return false;
    }
    return true;
}

From source file:Main.java

public static boolean checkIfInteger(String str) {
    Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
    return pattern.matcher(str).matches();
}