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 isMatches(String text) {
    String strPattern = "^[_a-zA-Z0-9]+$";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(text);
    return m.matches();
}

From source file:Main.java

public static boolean isEmail(String email) {
    if (email == null) {
        return false;
    }//from   www  .ja  v a 2s  .  c  o m
    String str = "^([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})(\\]?)$";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(email);

    return m.matches();
}

From source file:Main.java

public static boolean isCheckCode(String strCode) {
    String strPattern = "^[0-9a-zA-Z]{6}";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strCode);
    return m.matches();
}

From source file:Main.java

private static String extractPattern(String string, String pattern) {
    Pattern p = Pattern.compile(pattern);
    Matcher m = p.matcher(string);

    if (!m.find()) {
        return null;
    }/*from  www .  ja va 2  s  .  c  om*/
    return m.toMatchResult().group(1);
}

From source file:Main.java

public static boolean isCode(String strCode) {
    String strPattern = "^[0-9]{6}";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strCode);
    return m.matches();
}

From source file:Main.java

public static boolean checkIncludeChinese(String chinese) {
    Pattern regex = Pattern.compile("[\u4e00-\u9fa5]");
    return regex.matcher(chinese).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 isPassCode(String strCode) {
    String strPattern = "^[0-9a-zA-Z@*%#()><!_~]{6,12}";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strCode);
    return m.matches();
}

From source file:Main.java

public static boolean isEmail(String strEmail) {
    String strPattern = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(strEmail);
    return m.matches();
}

From source file:Main.java

public static boolean isLegalUrlParameters(String str) {
    String strPattern = "[&=\\s]+";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher(str);
    return m.find();
}