Example usage for java.lang String replaceFirst

List of usage examples for java.lang String replaceFirst

Introduction

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

Prototype

public String replaceFirst(String regex, String replacement) 

Source Link

Document

Replaces the first substring of this string that matches the given regular expression with the given replacement.

Usage

From source file:Main.java

public static String getAssetPath(String url) {
    return url.replaceFirst(getAssetsUrlPrefix(IP_ADDRESS), "");
}

From source file:Main.java

public static String dirtilyAddNamespaceForOracleESB(String rootElement, String xmlDoc) {
    xmlDoc = xmlDoc.replaceFirst("<" + rootElement,
            "<" + rootElement + " " + "xmlns=\"http://www.oracle.com/esb\"");
    return xmlDoc;
}

From source file:Main.java

public static String cleanXmlString(String xmlContent) {
    return xmlContent.replaceFirst(BOM_IDENTIFIER, XML_TAG_START);
}

From source file:Main.java

public static String localhost2RealMachine(String url) {
    return url.replaceFirst(getAssetsUrlPrefix(IP_ADDRESS_LOCALHOST), getAssetsUrlPrefix(IP_ADDRESS));
}

From source file:Main.java

/**
 * Popular sites uses the #! to indicate the importance of the following
 * chars. Ugly but true. Such as: facebook, twitter, gizmodo, ...
 *//*w  ww.j ava2 s. c o  m*/
public static String removeHashbang(String url) {
    return url.replaceFirst("#!", "");
}

From source file:Main.java

public static String unwrapFromXml(String xml) {
    return xml.replaceFirst(XML_OPEN_TAG, "").replaceFirst(XML_CLOSE_TAG, "").replaceAll("&apos;", "'");
}

From source file:Main.java

/**
 * Checks whether the filename looks legitimate
 */// ww  w .j  a  v a 2  s  .c o  m
public static boolean isFilenameValid(String filename) {
    filename = filename.replaceFirst("/+", "/"); // normalize leading
    // slashes
    return filename.startsWith(Environment.getDownloadCacheDirectory().toString())
            || filename.startsWith(Environment.getExternalStorageDirectory().toString());
}

From source file:Main.java

public static Bitmap base64ToBitmap(String base64Data) {
    byte[] bytes = Base64.decode(base64Data.replaceFirst("data:image/jpeg;base64,", "").trim(), Base64.DEFAULT);
    return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}

From source file:Main.java

public static String toLowerCase(String str, int beginIndex, int endIndex) {
    return str.replaceFirst(str.substring(beginIndex, endIndex),
            str.substring(beginIndex, endIndex).toLowerCase(Locale.getDefault()));
}

From source file:Main.java

public static Long getTwitterIdFromUrl(String sourceUrl) {
    String id = sourceUrl.replaceFirst("#!/", "");
    int index = id.lastIndexOf("/");
    if (index > 0) {
        index++;/*w ww  . jav a2s . c o  m*/
        try {
            return Long.parseLong(id.substring(index));
        } catch (NumberFormatException ex) {
        }
    }
    return null;
}