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 isIdOk(String Idstr) {
    //account//from w  w w.ja va2  s  .c o m
    String regex = "[\u4e00-\u9fa5_a-zA-Z0-9_]{2,30}";
    Pattern pattern = Pattern.compile(regex);
    return pattern.matcher(Idstr).matches();
}

From source file:Main.java

private static boolean match(String pattern, String str) {
    Pattern p = Pattern.compile(pattern);
    Matcher m = p.matcher(str);
    return m.find();
}

From source file:Main.java

public static boolean isNumeric(String str) {
    Pattern pattern = Pattern.compile("[0-9]+");
    return pattern.matcher(str).matches();
}

From source file:Main.java

public static boolean checkphone(String phonenumber) {
    String phone = "\\d{11}";
    Pattern p = Pattern.compile(phone);
    Matcher m = p.matcher(phonenumber);
    return m.matches();
}

From source file:Main.java

public static boolean checkChinese(String username) {
    String pstr = "[^x00-xff]";
    Pattern p = Pattern.compile(pstr);
    Matcher m = p.matcher(username);
    return m.find();
}

From source file:Main.java

public static String parseOptionalStringAttr(String paramString, Pattern paramPattern) {
    Matcher localMatcher = paramPattern.matcher(paramString);
    if ((localMatcher.find()) && (localMatcher.groupCount() == 1))
        return localMatcher.group(1);
    return null;/*  ww  w .  ja v a 2s. co m*/
}

From source file:Main.java

public static String strSpecial(String str) {
    String regEx = "[/\\:*?<>|\"\n\t]";
    Pattern p = Pattern.compile(regEx);
    Matcher m = p.matcher(str);
    return m.replaceAll("");
}

From source file:Main.java

public static String reSpecial(String str) {
    String regEx = "[/\\:*?<>|\"]";
    Pattern p = Pattern.compile(regEx);
    Matcher m = p.matcher(str);
    return m.replaceAll("");
}

From source file:Main.java

public static boolean isEmail(String email) {
    String str = "^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(email);
    return m.matches();

}

From source file:Main.java

public static String getDigital(String str) {
    String regEx = "[^0-9]";
    Pattern p = Pattern.compile(regEx);
    Matcher m = p.matcher(str);
    return m.replaceAll("").trim();
}