Example usage for java.lang String replace

List of usage examples for java.lang String replace

Introduction

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

Prototype

public String replace(CharSequence target, CharSequence replacement) 

Source Link

Document

Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.

Usage

From source file:Main.java

public static String getExtension(String fileName) {
    int lastDotPosition = fileName.lastIndexOf('.');
    String ext = fileName.substring(lastDotPosition + 1);
    ext = ext.replace("_", "");
    return ext.trim().toLowerCase();
}

From source file:Main.java

protected static String generateRandomBlobNameWithPrefix(String prefix) {
    if (prefix == null) {
        prefix = "";
    }//w ww.  j av a  2 s .c o m
    String blobName = prefix + UUID.randomUUID().toString();
    return blobName.replace("-", "");
}

From source file:de.shadowhunt.subversion.internal.ResourcePropertyUtils.java

static String escapedKeyNameXml(final String name) {
    return name.replace(COLON, MARKER);
}

From source file:de.shadowhunt.subversion.internal.ResourcePropertyUtils.java

static String unescapedKeyNameXml(final String name) {
    return name.replace(MARKER, COLON);
}

From source file:Main.java

public static String convertToCurrencyFormat(String amount) {
    double amountDouble = Double.parseDouble(amount);
    NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "IN"));
    String returnString = formatter.format(amountDouble).replace("Rs.", "");
    return returnString.replace("Rs", "").trim();
}

From source file:Main.java

public static String cleanSSID(String SSID) {
    String res = null;// w w  w  . j a  v a  2 s . c  om
    if (SSID != null) {
        res = SSID.replace("\"", "");
    }

    return res;
}

From source file:Main.java

public static Bundle parseUrl(String url) {
    Bundle ret;//from   w w  w  .  j  a  v a2s .c om
    url = url.replace("bdconnect", "http");
    try {
        URL urlParam = new URL(url);
        ret = decodeUrl(urlParam.getQuery());
        ret.putAll(decodeUrl(urlParam.getRef()));
        return ret;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}

From source file:Main.java

public static String normalizeName(String name) {

    String resp = name.trim();
    while (resp.indexOf("  ") != -1) {
        resp = resp.replace("  ", " ");
    }// w ww. j  a  va 2s .c o  m
    return resp;
}

From source file:Main.java

public static String filterHtml(String html) {
    Pattern pattern = Pattern.compile("<style[^>]*?>[\\D\\d]*?<\\/style>");
    Matcher matcher = pattern.matcher(html);
    String htmlStr = matcher.replaceAll("");
    pattern = Pattern.compile("<[^>]+>");
    String filterStr = pattern.matcher(htmlStr).replaceAll("");
    filterStr = filterStr.replace("&nbsp;", "");
    filterStr = filterStr.replace("&#13;", "");
    return filterStr.trim();
}

From source file:com.esri.geoportal.commons.utils.CrlfUtils.java

/**
 * Sanitizes string for log.//from   w  w w. j  av  a2 s  .  co  m
 * @param msg message to sanitize
 * @return sanitized message
 */
public static String sanitizeForLog(String msg) {
    String clean = msg != null ? msg.replace('\n', '_').replace('\r', '_') : "";
    clean = StringEscapeUtils.escapeHtml4(clean);
    if (!msg.equals(clean)) {
        clean += " (Encoded)";
    }
    return clean;
}