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 removeTags(String input) {
    String result = input;

    result = result.replaceAll("<([^<>]+)>", "");

    return result;
}

From source file:Main.java

public static String xmlConv(String input) {
    String s = input;

    s = s.replaceAll("&amp;", "&");
    s = s.replaceAll("&lt;", "<");
    s = s.replaceAll("&gt;", ">");
    s = s.replaceAll("&apos;", "'");
    s = s.replaceAll("&quot;", "\"");

    return s;//w  ww .  j  av  a 2 s  .  c  o m

}

From source file:Main.java

public static String getXmlEncodedDoubleQuotes(String value) {
    return value.replaceAll("\"", "&quot;");
}

From source file:Main.java

public static int convertPercent(String percent) {
    return Integer.parseInt(percent.replaceAll("[^\\d]", ""));
}

From source file:Main.java

public static String replaceNamedEntitiesWithNumericEntities(String value) {
    return value.replaceAll("&nbsp;", "&#160;");
}

From source file:Main.java

/**
 * Convert to LF//w  w w  .  ja va  2 s  . c o m
 * @param text
 * @return
 */
public static String convertToLf(String text) {
    String repCrlf = text.replaceAll("\r\n", "\n");
    String repLf = repCrlf.replaceAll("\r", "\n");
    return repLf;
}

From source file:Main.java

public static String unescapeXml(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 final static String makeShellCompatible(String name) {
    return name.replaceAll("[^a-zA-Z0-9_]", "_");
}

From source file:Main.java

public static String htmlspecialchars(String str) {
    str = str.replaceAll("&", "&amp;");
    str = str.replaceAll("<", "&lt;");
    str = str.replaceAll(">", "&gt;");
    str = str.replaceAll("\"", "&quot;");
    return str;//from   w w w . j  a v a  2  s .co  m
}

From source file:Main.java

/**
 * Returns a regular then marking word boundaries and ignoring case.
 * <p>/* w  ww . j  av  a  2s. co m*/
 * Example:<br />
 * "group\\s+by" becomes "\\b(?:(i?)group\\s+by)\\b"
 * </p>
 */
public static String word(String word) {
    return "\\b((?i)" + word.replaceAll("\\s+", "\\\\s+") + ")\\b";
}