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:Main.java

public static String stripOutLuceneHighlighting(String str) {
    str = str.replaceAll("<B>", "");
    str = str.replaceAll("</B>", "");
    str = str.replaceAll("<b>", "");
    str = str.replaceAll("</b>", "");
    return str;//from   w  w w . j  a  va2 s.c  o  m
}

From source file:Main.java

public static String escapeXml(String xmlString) {
    String result = xmlString;
    result.replaceAll("<", "&lt;");
    result.replaceAll(">", "&gt;");
    result.replaceAll("<", "&amp;");
    result.replaceAll("\"", "&quot;");
    result.replaceAll("'", "&apos;"); // &#039;
    result.replaceAll("\\", "&#092;");

    return result;
}

From source file:Main.java

public static List<String> replace(List<String> list, String find, String replace) {
    List<String> l = new ArrayList<String>();
    for (String aList : list) {
        l.add(aList.replaceAll(find, replace));
    }/* w  ww.  j  av  a2s.c  o m*/
    return l;
}

From source file:Main.java

/**
 * Convert to CRLF/*  w  w w .j  av a2s  .co  m*/
 * @param text
 * @return
 */
private static String convertToCrlf(String text) {
    String repCrlf = text.replaceAll("\r\n", "\n");
    String repLf = repCrlf.replaceAll("\r", "\n");
    String rep = repLf.replaceAll("\n", "\r\n");
    return rep;
}

From source file:Main.java

/** Replace critical characters by XML entities. */
static String quoteCharacterData(String s) {
    return s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
}

From source file:Main.java

public static boolean isInputEmpty(String stringToCheck) {
    stringToCheck = stringToCheck.replaceAll(" ", "");
    stringToCheck = stringToCheck.replaceAll("\n", "");
    return stringToCheck.isEmpty();
}

From source file:Main.java

/**
 * Wraps text with output tag.// w w  w  .j  a  va2  s  . c o m
 * 
 * @param taggedOutputName text to tag
 * @return tagged text
 */
public static String extractOutputName(String taggedOutputName) {
    return taggedOutputName.replaceAll(OUTPUT_TAG, "");
}

From source file:Main.java

public static String formatZhuiShuDateString(String dateString) {
    return dateString.replaceAll("T", " ").replaceAll("Z", "");
}

From source file:Main.java

/**
 * Remove HTML from a string./*from   w  ww. jav  a  2 s  . co m*/
 * 
 * @param text      The string containing HTML.
 * @return          The same string with all HTML removed.
 */
public static String removeHtml(String text) {
    return text.replaceAll("<[^>]+>", "");
}

From source file:com.textocat.textokit.commons.wfstore.DefaultWordformStorePrinter.java

private static final String escapeTabs(String src) {
    return src.replaceAll("\t", "\\t");
}