Example usage for java.util.regex Pattern CASE_INSENSITIVE

List of usage examples for java.util.regex Pattern CASE_INSENSITIVE

Introduction

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

Prototype

int CASE_INSENSITIVE

To view the source code for java.util.regex Pattern CASE_INSENSITIVE.

Click Source Link

Document

Enables case-insensitive matching.

Usage

From source file:core.plugin.mybatis.PageInterceptor.java

public static void main(String[] args) {
    List<String> tests = new ArrayList<String>();
    tests.add("select count(*) from abc \n\t\t where\n abc");
    tests.add("SELECT COUNT(*) from abc");
    tests.add(" select count (*) from abc");
    tests.add(" select count( *) from abc");
    tests.add("select count( * ),id from abc");
    tests.add("select * from abc");
    tests.add("select abc,test,fdas from abc");
    tests.add("select count(adb) from abc");
    tests.add("select count(0) from abc");
    tests.add("select min(count(*)) from abc");
    tests.add("update min(count(*)) from abc");
    tests.add("delete min(count(*)) from abc");
    Pattern p1 = Pattern.compile(SQL_SELECT_REGEX, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
    Pattern p2 = Pattern.compile(SQL_COUNT_REGEX, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
    for (String str : tests) {
        Matcher m1 = p1.matcher(str);
        Matcher m2 = p2.matcher(str);
        System.out.println("?: " + str);
        System.out.println(" select?? " + m1.matches());
        System.out.println(" count?? " + m2.matches());
        System.out.println();/*  w w  w.j a v a  2s. c  om*/
    }
}

From source file:Main.java

public static String getCsFromRE(String pt, String content) {
    Pattern pa1 = Pattern.compile(pt, Pattern.CASE_INSENSITIVE);
    Matcher matcher1 = pa1.matcher(content);
    if (matcher1.find()) {
        return matcher1.group(1);
    } else {/* w w w  .  java 2 s.c  o m*/
        return "";
    }
}

From source file:Main.java

public static String readValue(String whole, String key) {
    Pattern pattern = Pattern.compile(key + "=([\"'])(.+?)\\1", Pattern.CASE_INSENSITIVE);
    Matcher mat = pattern.matcher(whole);
    if (mat.find()) {
        return mat.group(2);
    } else {/*  www.j  a  v  a 2s  .c  om*/
        pattern = Pattern.compile(key + "=([^ \t\r\n\f\b\"'/>]+?)[ \t\r\n\f\b\"'/>]", Pattern.CASE_INSENSITIVE);
        mat = pattern.matcher(whole);
        if (mat.find()) {
            return mat.group(1);
        }
    }
    return "";
}

From source file:Main.java

/** Validate email address **/
public static boolean validateEmail(String email) {
    Pattern p = Pattern.compile("[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}", Pattern.CASE_INSENSITIVE);
    Matcher m = p.matcher(email);
    return m.matches();
}

From source file:Main.java

public static String getProjectByUrl(String url) {
    Pattern pattern = Pattern.compile("https://(\\p{Ll}+).(.*)", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(url);
    if (!matcher.matches())
        throw new IllegalArgumentException("Regex fail. not matched. Url: " + url);

    return matcher.group(1);
}

From source file:Main.java

/** Validate telephone number **/
public static boolean validatePhone(String phone, int length) {
    Pattern p = Pattern.compile(String.format("[0-9]{%d}", length), Pattern.CASE_INSENSITIVE);
    Matcher m = p.matcher(phone);
    return m.matches();
}

From source file:Main.java

public static Pattern getTagAttrPattern(String tagAttrName) {
    return Pattern.compile(tagAttrName + PTN_TAGATTR, Pattern.CASE_INSENSITIVE);
}

From source file:Main.java

public static boolean likeFUC(String str, String pattenStr) {
    boolean result = false;
    if (str != null && !str.equals("")) {
        Matcher m = Pattern.compile(pattenStr, Pattern.CASE_INSENSITIVE).matcher(str);
        while (m.find()) {
            result = true;/*from   w w  w.  j av  a  2s  .c o m*/
        }
    }
    return result;
}

From source file:Main.java

public static boolean isValidUsername(String username) {
    String expression = "^[a-zA-Z0-9_]+$";
    Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(username);
    return matcher.matches();
}

From source file:Main.java

public static boolean isLinkAvailable(String link) {
    Pattern pattern = Pattern.compile(
            "^(http://|https://)?((?:[A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\\.)+([A-Za-z]+)[/\\?\\:]?.*$",
            Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(link);
    return matcher.matches();
}