Example usage for java.util.regex Pattern matcher

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

Introduction

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

Prototype

public Matcher matcher(CharSequence input) 

Source Link

Document

Creates a matcher that will match the given input against this pattern.

Usage

From source file:Main.java

public static boolean isNumber(String str) {
    String NUMBER_PATTERN = "^\\d+$";
    Pattern p = Pattern.compile(NUMBER_PATTERN);
    Matcher m = p.matcher(str);
    return m.matches();
}

From source file:Main.java

private static boolean isEmail(String text) {
    String reg = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
    Pattern regex = Pattern.compile(reg);
    Matcher matcher = regex.matcher(text);
    return matcher.matches();

}

From source file:Main.java

public static boolean matcherRegex(String regex, String str) {
    Pattern pattern = Pattern.compile(regex);
    return pattern.matcher(str).matches();
}

From source file:Main.java

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

From source file:Main.java

private static String getFileNameByUrl(String url) {
    // TODO Auto-generated method stub
    Pattern p = Pattern.compile("\\w+");
    Matcher m = p.matcher(url);
    String filename = "";
    while (m.find()) {
        String str = m.group();/*from   w w  w.  j  a  v a 2 s .co m*/
        filename = str;
    }
    return filename;
}

From source file:Main.java

public static boolean checkPhone(String num) {
    String mobile = num;/*w  w  w.  j  a v a2 s. c  om*/
    if (TextUtils.isEmpty(mobile)) {
        return false;
    }
    String exp = "(1)[0-9]{10}$";
    Pattern p = Pattern.compile(exp);
    Matcher m = p.matcher(mobile);
    boolean isPhoneNum = m.matches();
    return isPhoneNum;
}

From source file:Main.java

public static boolean isMobilePhoneNumber(String phoneNumber) {
    //  /^0{0,1}(13[4-9]|15[7-9]|15[0-2]|18[7-8])[0-9]{8}$/; 
    String reg_VerCode = "^(13|14|15|18)[0-9]{9}$";

    Pattern p = Pattern.compile(reg_VerCode);
    Matcher m = p.matcher(phoneNumber);
    return m.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

static public Boolean rutValidation(String rut) {
    Pattern p = Pattern.compile(rut_pattern);
    Matcher m = p.matcher(rut);
    while (m.find()) {
        return true;
    }//from   www .  ja  v  a  2  s . c om
    return false;
}

From source file:Main.java

public static boolean isMobilePhoneNumber(String number) {
    String regx = "^(13[0-9]|15[0-9]|18[0-9]|14[5|7])\\d{8}$";
    Pattern pattern = Pattern.compile(regx);
    Matcher matcher = pattern.matcher(number);
    return matcher.find();
}