Example usage for java.lang String replaceAll

List of usage examples for java.lang String replaceAll

Introduction

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

Prototype

public String replaceAll(String regex, String replacement) 

Source Link

Document

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

Usage

From source file:io.apiman.manager.api.gateway.rest.GatewayClientTest.java

private static String normalize(String output) {
    return output.replaceAll("\r\n", "\n");
}

From source file:Main.java

public static String toHtml(String string) {
    if (string == null)
        return "";
    string = string.replaceAll("&", "&");
    string = string.replaceAll("\"", """);
    string = string.replaceAll("<", "&lt;");
    string = string.replaceAll(">", "&gt;");
    // string = string.replaceAll("\r\n", "\n");
    string = string.replaceAll("\n", "<br>\n");
    string = string.replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
    string = string.replaceAll(" ", "&nbsp;");
    return string;
}

From source file:Main.java

public static String decodeString(String strData) {
    if (strData == null) {
        return "";
    }//from   ww w. j  a va  2 s .c  o m
    return strData.replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&apos;", "'")
            .replaceAll("&quot;", "\"").replaceAll("&amp;", "&");
}

From source file:Main.java

public static String millisToStringFilename(long millis) {
    String dateStr = millisToStringDate(millis, "yyyy-MM-dd HH:mm:ss");
    return dateStr.replaceAll("[- :]", "_");
}

From source file:com.edgenius.core.util.StringEscapeUtil.java

public static String unescapeHtml(String html) {
    if (html == null)
        return null;

    String str = StringEscapeUtils.unescapeHtml(html);
    return str.replaceAll(space, " ");
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step7aLearningDataProducer.java

public static String multipleParagraphsToSingleLine(String s) {
    return s.replaceAll("\n", " <br/> ");
}

From source file:Main.java

public static final String replaceValueString(String value) {
    if (value == null)
        return "null";

    value = value.replaceAll("\r\n", "<femtobr>");
    value = value.replaceAll("\r", "<femtobr>");
    value = value.replaceAll("\n", "<femtobr>");
    value = value.replaceAll("\t", "<femtotab>");
    return value;
}

From source file:Main.java

public static String trimString(String text) {
    String newText = null;//from w w  w  .  j  a  v  a  2s  . c o m
    if (text != null) {
        newText = text.replaceAll("^(\\s*)", "");
        newText = newText.replaceAll("(\\s*)$", "");
    }
    return newText;
}

From source file:Main.java

private static String sanitizeFileName(String fileName) {
    StringBuilder sanitized = new StringBuilder();
    sanitized.append(fileName.replaceAll(FILE_NAME_PATTERN, "$1").replaceAll("[^A-Za-z0-9_\\-]", "_"));
    sanitized.append(fileName.replaceAll(FILE_NAME_PATTERN, "$2"));
    return sanitized.toString();
}

From source file:edu.mayo.cts2.framework.core.util.EncodingUtils.java

/**
 * Encode colon./* w w w  .  j  ava  2  s  . c om*/
 *
 * @param text the text
 * @return the string
 */
private static String encodeColon(String text) {
    return text.replaceAll(SCOPED_ENTITY_NAME_SEPERATOR, ESCAPE_CHAR);
}