Example usage for java.lang String contains

List of usage examples for java.lang String contains

Introduction

In this page you can find the example usage for java.lang String contains.

Prototype

public boolean contains(CharSequence s) 

Source Link

Document

Returns true if and only if this string contains the specified sequence of char values.

Usage

From source file:Main.java

public static boolean isMobilePhone(String tel) {
    if (tel.contains(" ")) {
        tel = tel.replaceAll(" ", "");
    }/*from  w  w w. ja va2 s  .  com*/

    if (tel.contains("-")) {
        tel = tel.replaceAll("-", "");
    }
    Pattern p = Pattern.compile("(1)\\d{10}$");
    return p.matcher(tel).matches();
}

From source file:Main.java

public static boolean isMSIEOld(String userAgent) {
    if (userAgent.contains("MSIE ") && !userAgent.contains("Opera")) {
        int index = userAgent.indexOf("MSIE ");
        int start = index + "MSIE ".length();
        int end = userAgent.indexOf('.', start);
        int version = Integer.parseInt(userAgent.substring(start, end));
        return version < 9;
    }/*from   w w w .  j  av a2  s. c om*/
    return false;
}

From source file:Main.java

public static Boolean isEnglishName(String input) {
    if (!input.contains("/")) {
        return false;
    }/*w  w  w.  j  a  va  2  s .  c  om*/
    String str = "^[a-zA-Z][a-z A-Z/]*$";
    Pattern p = Pattern.compile(str);
    Matcher m = p.matcher(input);
    return m.matches();
}

From source file:Main.java

public static String getResouceTitle(String filename) {
    if (filename.contains("-")) {
        return getFileNameWithoutExt(filename).split("-")[1];
    }/* www .  ja v  a2s. c  o  m*/
    return getFileNameWithoutExt(filename);
}

From source file:Main.java

public static boolean isMultChat(String jid) {
    if (jid != null && jid.contains("conference")) {
        return true;
    }/*from   www.  jav  a  2  s.  c  o  m*/
    return false;
}

From source file:Main.java

public static String removeGeneric(String s) {
    if (s.contains("<"))
        return s.substring(0, s.lastIndexOf("<"));
    else/*ww  w . j a v  a  2 s.  co m*/
        return s;
}

From source file:Main.java

public static String removeLastIdentifier(String s) {
    if (s.contains("."))
        return s.substring(0, s.lastIndexOf("."));
    else/*  w w w .j  a  va  2  s . c o  m*/
        return new String();
}

From source file:Main.java

private static String resType(String url) {
    if (url.contains(".jpg")) {
        return "jpg";
    } else if (url.contains(".css")) {
        return "css";
    } else if (url.contains(".js")) {
        return "js";
    } else if (url.contains(".png")) {
        return "png";
    } else if (url.contains(".jpeg")) {
        return "jpeg";
    } else {//  w  w  w.  java  2  s .c om
        return "gif";
    }
}

From source file:Main.java

/**
 * "07:01" = 7*60*60*1000+1000;/*from w w w  . ja va  2s  .c  o  m*/
 * @return
 */
public static long parseToTimeInMillis2(String string) {
    if (string.contains(":")) {
        String[] srs = string.split(":");
        int h = Integer.valueOf(srs[0]);
        int m = Integer.valueOf(srs[1]);
        long hour = h * 60 * 60 * 1000;
        long mm = m * 60 * 1000;
        return hour + mm;
    }
    return 0;
}

From source file:Main.java

public static String getFileName(String path) {
    if (path != null && path.contains("/")) {
        return new File(path).getName();
    }//from   ww  w . j  a v  a 2s .  c  om
    return path;
}