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 escapeXmlProperty(final String value) {
    return value.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot")
            .replace("'", "&apos;");
}

From source file:Main.java

/**
 * /*from  w w w . j a v  a  2  s .c  om*/
 * @param str
 * @return
 */
public static String uncompact(String str) {
    str = str.replace("___", "#");
    str = str.replace("_", " ");
    str = str.replace("#", " ");
    return str;
}

From source file:Main.java

public static String escapeQuotes(String s) {
    s = s.replace("\\", "\\\\");
    s = s.replace("\"", "\\\"");

    return s;//  ww  w.  j  ava  2 s . c  om
}

From source file:Main.java

/**
 * Get New-line character remove//from  w  w  w  .j  a  v a2s . c o m
 *
 * @param message changed message
 * @return Removed New-line character
 */
public static String removeNewLineCharacter(String message) {
    return message.replace(System.getProperty("line.separator"), "");
}

From source file:Main.java

/**
 * Encode user email to use it as a Firebase key (Firebase does not allow "." in the key name)
 * Encoded email is also used as "userEmail", list and item "owner" value
 */// ww  w .j av a2  s .  co  m
public static String encodeEmail(String userEmail) {
    return userEmail.replace(".", ",");
}

From source file:Main.java

public static String suggestRLMOutputPath(final String mainClass) {
    return mainClass.replace('.', '/') + ".swf";
}

From source file:Main.java

public static String unstripHtml(String data) {
    data = data.replace("&quot;", "\"");
    data = data.replace("&#39;", "'");
    data = data.replace("&lt;", "<");
    data = data.replace("&gt;", ">");
    data = data.replace("&amp;", "&");
    return data;/*from   ww  w.  j  ava2 s. co m*/
}

From source file:Main.java

public static String columnAlias(String columnSelection) {
    return columnSelection.replace(".", "_");
}

From source file:Main.java

/**
 * Email is being decoded just once to display real email in AutocompleteFriendAdapter
 *
 * @see com.udacity.firebase.shoppinglistplusplus.ui.sharing.AutocompleteFriendAdapter
 *///from   w ww  . j a v a 2s.c om
public static String decodeEmail(String userEmail) {
    return userEmail.replace(",", ".");
}

From source file:Main.java

/**
 * Kusini Unguja, TZ -> Kusini_Unguja
 * @param address/*from  w  w  w.j  av a  2s. c  o m*/
 * @return
 */
public static String getConcatenatedCityFromAddress(String address) {

    return address.replace(" ", "_").split(",")[0];
}