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

/**
 * Simple method to remove all spaces, parentheses, and hyphens
 * @param input String to adjust/*  w  w  w .j  a v  a  2  s  .c o m*/
 * @return formatted String
 */
public static String formatPhoneRemoveFormatting(String input) {
    if (input == null) {
        return null;
    }
    input = input.replace("(", "");
    input = input.replace(")", "");
    input = input.replace("-", "");
    input = input.replace(" ", "");
    input = input.trim();
    return input;
}

From source file:Main.java

public static String removeQuoteInString(String originString) {
    if (originString != null && (!"".equals(originString))) {
        return originString.replace("\"", "");
    }/*w  w  w . j av a  2s  .c o m*/

    return "";

}

From source file:com.github.tomakehurst.wiremock.common.SafeNames.java

public static String makeSafeNameFromUrl(String urlPath) {
    String startingPath = urlPath.replace("/", "_");
    return makeSafeName(startingPath);
}

From source file:Main.java

/**
 * Replaces all <tt>'<'</tt> characters with <tt>'&lt;'</tt>
 * @param aString//from w w w. java2  s.c  o m
 * @return
 */
private static String escapeLessThanSigns(String aString) {
    return aString.replace("<", "&" + PREDEFINED_ENTITY_LESSTHAN_SIGN + ";");
}

From source file:Main.java

/**
 * Replaces all <tt>'\"'</tt> characters with <tt>'&quot;'</tt>
 * @param aString//from www .j  a va 2 s  . co m
 * @return
 */
private static String escapeQuotes(String aString) {
    return aString.replace("\"", "&" + PREDEFINED_ENTITY_QUOTES + ";");
}

From source file:Main.java

/**
 * Convert an encoding name from the java encoding name
 * which often omits a hyphen in the name to the standard
 * XML encoding name with hyphens./* w ww . jav a 2 s.  com*/
 *
 * @param encodingName The raw name of the encoding.
 * @return The corresponding XML encoding name.
 */
public static String toXmlEncodingName(String encodingName) {
    if (encodingName.matches("UTF\\d{1,2}")) {
        encodingName = encodingName.replace("UTF", "UTF-");
    } else if (encodingName.matches("ISO\\d{4}\\.*")) {
        encodingName = encodingName.replace("ISO", "ISO-");
    }
    return encodingName;
}

From source file:com.netflix.imfutility.itunes.locale.LocaleHelper.java

public static Locale fromITunesLocale(String locale) {
    return LocaleUtils.toLocale(locale.replace("-", "_"));
}

From source file:com.opendoorlogistics.studio.dialogs.AboutBoxDialog.java

public static String replaceVersionNumberTags(String s) {
    long maxMemoryMb = Runtime.getRuntime().maxMemory() / (1024 * 1024);
    s = s.replace("VERSION_NUMBER", AppConstants.getAppVersion().toString());
    s = s.replace("JAVA_VERSION", System.getProperty("java.version") + ", max memory " + maxMemoryMb + " MB");
    return s;/*from w w w  . j a  v  a 2s  .  c o m*/
}

From source file:com.Sanish.automatedserver.filter.MeaningFilter.java

public static String filter(String content) {
    content = StringEscapeUtils.unescapeHtml4(content);
    content = content.replace(";", "");
    content = content.replace("<br/>", "\n");
    content = content.replaceAll("<a href(.*?)>", "");
    content = content.replaceAll("</a>", "");
    return content;

}

From source file:com.netflix.spinnaker.clouddriver.artifacts.CredentialReader.java

public static String credentialsFromFile(String filename) {
    try {/*w w  w  .  j  a  va2s  . c om*/
        String credentials = FileUtils.readFileToString(new File(filename));
        return credentials.replace("\n", "");
    } catch (IOException e) {
        throw new IllegalStateException("Could not read credentials file: " + filename, e);
    }
}