Example usage for java.util.regex Matcher find

List of usage examples for java.util.regex Matcher find

Introduction

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

Prototype

public boolean find() 

Source Link

Document

Attempts to find the next subsequence of the input sequence that matches the pattern.

Usage

From source file:Main.java

public static String patternLoginVerificationCode(String patternContent) {
    if (TextUtils.isEmpty(patternContent)) {
        return null;
    }/*  w  ww  . ja  v  a2s  . c  o  m*/
    Pattern p = Pattern.compile("(?<!\\d)\\d{6}(?!\\d)");
    Matcher matcher = p.matcher(patternContent);
    if (matcher.find()) {
        return matcher.group();
    }
    return null;
}

From source file:Main.java

public static String patternCode(String patternContent) {
    if (TextUtils.isEmpty(patternContent)) {
        return null;
    }//from  w w  w  .  java2s.  c  om
    Pattern p = Pattern.compile("(?<!\\d)\\d{4}(?!\\d)");
    Matcher matcher = p.matcher(patternContent);
    if (matcher.find()) {
        return matcher.group();
    }
    return null;
}

From source file:Main.java

public static boolean isEmailFormat(String email) {

    boolean tag = true;
    final String pattern1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
    final Pattern pattern = Pattern.compile(pattern1);
    final Matcher mat = pattern.matcher(email);
    if (!mat.find()) {
        tag = false;/*ww  w.  j ava2s .c  o  m*/
    }
    return tag;
}

From source file:Main.java

public static boolean ifhaschinese(String string) {
    boolean haschinese = false;
    String expre = "[\u4e00-\u9fa5]";
    CharSequence inputStr = string;
    Pattern pattern = Pattern.compile(expre);
    Matcher matcher = pattern.matcher(inputStr);
    if (matcher.find()) {
        haschinese = true;// w  ww.  j  a  va2  s  .c o  m
    }
    return haschinese;
}

From source file:Main.java

private static boolean isJCBCard(String creditCardNumber) {
    Pattern pattern = Pattern.compile(JCBCreditCardPattern);
    Matcher matcher = pattern.matcher(creditCardNumber);
    return matcher.find();
}

From source file:Main.java

private static boolean isDinersClubCard(String creditCardNumber) {
    Pattern pattern = Pattern.compile(DinersClubCreditCardPattern);
    Matcher matcher = pattern.matcher(creditCardNumber);
    return matcher.find();
}

From source file:Main.java

private static boolean isVISACard(String creditCardNumber) {
    Pattern pattern = Pattern.compile(VISACreditCardPattern);
    Matcher matcher = pattern.matcher(creditCardNumber);
    return matcher.find();
}

From source file:Main.java

private static boolean isDiscoverCard(String creditCardNumber) {
    Pattern pattern = Pattern.compile(DiscoverCreditCardPattern);
    Matcher matcher = pattern.matcher(creditCardNumber);
    return matcher.find();
}

From source file:Main.java

private static boolean isAmericanExpress(String creditCardNumber) {
    Pattern pattern = Pattern.compile(AmericanExpressCreditCardPattern);
    Matcher matcher = pattern.matcher(creditCardNumber);
    return matcher.find();
}

From source file:Main.java

public static List<String> getMatches(String regex, CharSequence input) {
    if (input == null)
        return null;
    List<String> matches = new ArrayList<>();
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(input);
    while (matcher.find()) {
        matches.add(matcher.group());/*from   w  w  w.  ja  v  a2 s.  c om*/
    }
    return matches;
}