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

private static boolean isNumeric(String str) {
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (isNum.matches()) {
        return true;
    } else {/*from  w ww. j av  a2 s .  c om*/
        return false;
    }
}

From source file:Main.java

public static boolean hasChinese(String str) {
    if (TextUtils.isEmpty(str))
        return false;
    else {//  www. j  a  v  a 2 s.c om
        String regEx = "[\u4e00-\u9fa5]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        if (m.find())
            return true;
        else
            return false;
    }
}

From source file:Main.java

public static boolean isChinese(String str) {
    String check = "^[\u4e00-\u9fa5]+$";
    Pattern regex = Pattern.compile(check);
    Matcher matcher = regex.matcher(str);
    if (matcher.matches()) {
        return true;
    } else {// w w  w .j av a  2  s  .c o  m
        return false;
    }

}

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 isNumeric(String str) {
    if ("".equals(str))
        return false;
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (!isNum.matches()) {
        return false;
    }/*  ww  w  .  j a v  a  2 s  .c o m*/
    return true;
}

From source file:Main.java

public static boolean checkIP(String IP) {
    if (null != IP) {
        String regex = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(IP);
        return matcher.matches();
    }//from ww w  . jav a 2s .com
    return false;
}

From source file:Main.java

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

From source file:Main.java

public static boolean isNameValid(String name) {

    final String NAME_PATTERN = "[A-Z][a-z]+( [A-Z][a-z]+)?";
    Pattern pattern = Pattern.compile(NAME_PATTERN);
    Matcher matcher = pattern.matcher(name);
    return matcher.matches();
}

From source file:Main.java

public static boolean isNumber(String number) {
    if (TextUtils.isEmpty(number))
        return false;
    else {//from w w  w.  j  av a 2 s .  c  o m
        Pattern p = Pattern.compile("[0-9]*");
        Matcher m = p.matcher(number);
        if (m.matches())
            return true;
        else
            return false;
    }
}