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 validateIp(String str) {
    Pattern pattern = Pattern.compile("[0-9],.");
    Matcher matcher = pattern.matcher(str);

    return matcher.matches();
}

From source file:Main.java

public static boolean MatchRegExp(String _str, String _regexp) {
    Pattern pattern = Pattern.compile(_regexp);
    Matcher matcher = pattern.matcher(_str);
    boolean matched = matcher.matches();
    return matched;
}

From source file:Main.java

public static String replaceBlankWithSpace(String str) {
    String dest = "";
    if (str != null) {
        Pattern p = Pattern.compile("\t|\r|\n");
        Matcher m = p.matcher(str);
        dest = m.replaceAll("");
    }/*from  ww  w  .java2 s. c  o  m*/
    return dest;
}

From source file:Main.java

public static String trimNewLine(String str) {
    if (TextUtils.isEmpty(str))
        return "";

    str = str.trim();//from  ww w  . j  a v  a2  s .  c  o  m
    Pattern p = Pattern.compile("\t|\r|\n");
    Matcher m = p.matcher(str);
    String dest = m.replaceAll("");
    return dest;
}

From source file:Main.java

public static boolean isMucNameContentLegal(String mucName) {

    boolean bret = false;
    if (TextUtils.isEmpty(mucName)) {
        return bret;
    }//from   w w  w  . j a va 2s.  c  o m
    Pattern p = Pattern.compile(MUC_NAME_PATTEN);
    bret = p.matcher(mucName).matches();
    return bret;
}

From source file:Main.java

public static boolean isChinaPhoneNumber(String phoneNum) {
    String PHONE_NUMBER_PATTERN = "^1[3578]\\d{9}";
    Pattern p = Pattern.compile(PHONE_NUMBER_PATTERN);
    Matcher m = p.matcher(phoneNum);
    return m.matches();
}

From source file:Main.java

public static boolean isNumeric(String str) {
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (!isNum.matches())
        return false;
    return true;//from ww w . j  a v  a 2  s.  c  o m
}

From source file:Main.java

public static boolean isInternationalPhoneNumber(String phoneNum) {
    String PHONE_NUMBER_PATTERN = "^\\d{1,4}-\\d{3,11}$";
    Pattern p = Pattern.compile(PHONE_NUMBER_PATTERN);
    Matcher m = p.matcher(phoneNum);
    return m.matches();
}

From source file:Main.java

public static boolean checkChineseInString(String name) {
    Pattern p = Pattern.compile(pattern_chinese);
    Matcher matcher = p.matcher(name);
    return matcher.find();
}

From source file:Main.java

public static boolean matching(String regex, String input) {
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(input);
    return matcher.matches();
}