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:Main.java

public static String uuidToString(UUID uuid) {
    String longUUID = uuid.toString();
    Pattern pattern = Pattern.compile("0000(.{4})-0000-1000-8000-00805f9b34fb", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(longUUID);
    if (matcher.matches()) {
        // 16 bit UUID
        return matcher.group(1);
    } else {//from  w  ww .  java 2s . c om
        return longUUID;
    }
}

From source file:Main.java

public static String matchUrl(String text) {
    if (TextUtils.isEmpty(text)) {
        return null;
    }/*from www. ja v a 2  s  .  c o  m*/
    Pattern p = Pattern.compile("[http]+[://]+[0-9A-Za-z:/[-]_#[?][=][.][&]]*", Pattern.CASE_INSENSITIVE);
    Matcher matcher = p.matcher(text);
    if (matcher.find()) {
        return matcher.group();
    } else {
        return null;
    }
}

From source file:Main.java

public static boolean isEmail(String email) {

    if (TextUtils.isEmpty(email))
        return false;

    String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";

    Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);

    if (matcher.matches())
        return true;
    else//w w w  . ja  va 2s.  c  o  m
        return false;

}

From source file:Main.java

public static boolean isEmailValid(String email) {
    boolean isValid = false;

    String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
    CharSequence inputStr = email;

    Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(inputStr);
    if (matcher.matches()) {
        isValid = true;//  w w  w.  j av a2 s . co  m
    }
    return isValid;
}

From source file:Main.java

public static String getHrefInnerHtml(String href) {

    if (isEmpty(href)) {
        return "";
    }//ww w  .  ja v a  2 s.c  o m

    String hrefReg = ".*<[\\s]*a[\\s]*.*>(.+?)<[\\s]*/a[\\s]*>.*";
    Pattern hrefPattern = Pattern.compile(hrefReg, Pattern.CASE_INSENSITIVE);
    Matcher hrefMatcher = hrefPattern.matcher(href);
    if (hrefMatcher.matches()) {
        return hrefMatcher.group(1);
    }
    return href;
}

From source file:Main.java

public static Pattern getUrlPattern() {
    return Pattern.compile(
            "^(http|www|ftp|)?(://)?(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*((:\\d+)?)(/(\\w+(-\\w+)*))*(\\.?(\\w)*)(\\?)?(((\\w*%)*(\\w*\\?)*(\\w*:)*(\\w*\\+)*(\\w*\\.)*(\\w*&)*(\\w*-)*(\\w*=)*(\\w*%)*(\\w*\\?)*(\\w*:)*(\\w*\\+)*(\\w*\\.)*(\\w*&)*(\\w*-)*(\\w*=)*)*(\\w*)*)$",
            Pattern.CASE_INSENSITIVE);
}

From source file:Main.java

public static boolean isEmail(String email) {

    if (TextUtils.isEmpty(email))
        return false;

    String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";

    Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);

    return matcher.matches();

}

From source file:Main.java

public static boolean isEmail(String email) {
    if (TextUtils.isEmpty(email)) {
        return false;
    }// w  w  w  .j  a va  2s. com
    String reg = "^[0-9a-z_-][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}\\.){1,4}[a-z]{2,4}$";
    Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static String toHref(String title) {
    StringBuffer sb = new StringBuffer(title);
    Pattern pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
    Matcher mat = pat.matcher(title);
    int index = 0;
    int index1 = 0;
    while (mat.find()) {
        String url = mat.group();
        //System.out.println(url);
        if (url.indexOf("http://") != 0)
            url = "http://" + url;
        Object obj[] = { "'" + url + "'" };
        String a = MessageFormat.format(A1, obj);
        int l = a.length();
        index += index1;//w  w  w  . j a v  a  2 s. c  o m
        sb.insert(mat.start() + index, a);
        index += l;
        sb.insert((mat.end()) + index, A2);
        index1 = A2.length();
    }
    return sb.toString();
}

From source file:Main.java

public static boolean checkEmailFormat(String email) {
    if (TextUtils.isEmpty(email)) {
        return false;
    }/* www  . j a  v  a2 s.  c  o m*/
    String reg = "^[0-9a-z_-][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}\\.){1,4}[a-z]{2,4}$";
    Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}