Example usage for java.lang String indexOf

List of usage examples for java.lang String indexOf

Introduction

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

Prototype

public int indexOf(String str) 

Source Link

Document

Returns the index within this string of the first occurrence of the specified substring.

Usage

From source file:Main.java

public static String getDomainFromUri(String domain) {
    if (domain.indexOf("//") > -1)
        domain = domain.substring(domain.indexOf("//") + 2);
    if (domain.endsWith("/"))
        domain = domain.substring(0, domain.indexOf("/"));
    if (domain.contains(":"))
        domain = domain.substring(0, domain.indexOf(":"));
    return domain;
}

From source file:Main.java

public static String getRidOfHeader(String node) {
    int pos = node.indexOf("?>");
    pos = node.indexOf('<', pos);
    return node.substring(pos);
}

From source file:Main.java

/**
 * Strip off namespace prefix/*from w  w w. j a  v  a2s . c o  m*/
 */
private static String getLocalPart(String tagName) {
    if (tagName.indexOf(":") > 0) {
        return tagName.split(":")[1];
    } else {
        return tagName;
    }
}

From source file:Main.java

/**
 * Quick and naive check for possible html-content of a string.
 *
 * @param str//  w w w .  ja  va2s  . c  o  m
 * @return True, if <code>str</code> could contain html
 */
public static boolean containsHtml(final String str) {
    return str.indexOf('<') != -1 || str.indexOf('&') != -1;
}

From source file:Main.java

public static boolean isdouhao(String name) {
    int aa = name.indexOf("|");
    if (aa >= 0) {
        return false;
    } else {/*from   ww  w.j  a v  a 2  s . c  o  m*/
        return true;
    }
}

From source file:Main.java

public static String trimString(String val) {
    return val.substring(val.indexOf('['));
}

From source file:Main.java

/**
 * Finds the cursor position in the specific text
 * //www . j  a  v a 2s  .  com
 * @param text
 * @return
 */
public static int findCursorOffset(String text) {
    return text.indexOf("|");
}

From source file:Replace.java

public static String replace(String oldStr, String newStr, String inString) {
    int start = inString.indexOf(oldStr);
    if (start == -1) {
        return inString;
    }/*w  w  w . j a v  a 2  s . c o m*/
    StringBuffer sb = new StringBuffer();
    sb.append(inString.substring(0, start));
    sb.append(newStr);
    sb.append(inString.substring(start + oldStr.length()));
    return sb.toString();
}

From source file:Main.java

public static boolean isdouhao1(String name) {
    int aa = name.indexOf("|");
    int bb = name.indexOf(" ");
    if (aa >= 0 && bb >= 0) {
        return false;
    } else {/*  w w w  .  j  ava  2 s .co  m*/
        return true;
    }
}

From source file:Main.java

private static String AddYear(String paramString1, String paramString2) {
    int i = paramString2.indexOf("yyyy");
    return paramString1.substring(0, i).concat(String.valueOf(Calendar.getInstance().get(1)))
            .concat(paramString1.substring(i));
}