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 is18IDcard(String idString) {
    Pattern p = Pattern
            .compile("^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$");
    Matcher m = p.matcher(idString);
    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 isTopMobileNO(String mobiles) {
    Pattern p = Pattern.compile("^((13[0-9])|(15[0-9])|(18[0-9])|(14[0-9])|(17[0-9]))\\d{4}$");
    Matcher m = p.matcher(mobiles);
    return m.matches();
}

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 regexCode2(String str) {
    Pattern pattern = Pattern.compile("^[0-9]*$"); // TODO
    Matcher isNum = pattern.matcher(str);
    return isNum.matches();
}

From source file:Main.java

public static boolean regexPhone(String str) {
    Pattern pattern = Pattern.compile("^((13|14|15|17|18)+)\\d{9}$");
    Matcher isNum = pattern.matcher(str);
    return isNum.matches();
}

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);
    System.out.println(m.matches() + "---");
    return m.matches();
}

From source file:Main.java

public static boolean isPhoneHomeNum(String num) {
    Pattern p = Pattern.compile(
            "^(((13[0-9])|(15([0-3]|[5-9])|170)|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{8})$");
    Matcher m = p.matcher(num);//from w  w  w .java2  s .  c  o  m
    return m.matches();
}

From source file:Main.java

public static boolean isPhoneNum(String num) {
    Pattern pattern = Pattern.compile("^((13[0-9])|(15[0-9])|(18[0-9])|(147)|(17[0|6|7|8]))\\d{8}$");
    Matcher matcher = pattern.matcher(num);
    return matcher.matches();
}

From source file:Main.java

public static boolean isMobileNumber(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();
}