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 isEmail(String email) {
    return Pattern.compile(".+@.+\\.[a-z]+").matcher(email).matches();
}

From source file:Main.java

public static boolean isValidateQQId(String s) {
    return Pattern.compile("^[0-9]+$").matcher(s).matches();
}

From source file:Main.java

public static boolean isEmail(String email) {
    return 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).matches();/*from  www  .ja v a2 s .c om*/
}

From source file:Main.java

public static boolean checkAmount(String money) {
    return Pattern.compile("^([2-9]|[1-9][0-9])\\d*00$").matcher(money).matches();
}

From source file:Main.java

public static boolean validateUrl(String url) {
    return Pattern
            .compile("^(file|gopher|news|nntp|telnet|https?|ftps?|sftp)://([a-z0-9-]+\\.)+[a-z0-9]{2,4}.*$")
            .matcher(url).find();/* w w w  .  j  av  a 2  s  . c  o m*/
}

From source file:Main.java

public static boolean checkPass(String password) {
    return Pattern.compile("^[^\\u4e00-\\u9fa5^ ]{6,18}$").matcher(password).matches();
}

From source file:Main.java

public static boolean isHaveLowerCase(String text) {
    return Pattern.compile("(?i)[a-z]").matcher(text).find();
}

From source file:Main.java

public static boolean isMobileNO2Contact(String mobiles) {
    return Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$").matcher(mobiles).matches();
}

From source file:Main.java

public static boolean isAlphabeticOrNumberic(String str) {
    return Pattern.compile("[A-Za-z0-9]*").matcher(str).matches();
}

From source file:Main.java

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