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

/**
 * if the search string in HQL has the "'", when call the hibernate search method,
 * will get error. so must replace the "'" to "''", it will work.
 *//*from  w  w w  . j  av  a  2 s.c o m*/
public static String FixTermIllegalChar(String term) {
    term = term.replaceAll("'", "''");

    return term;
}

From source file:Main.java

/**
 * removing comma and parse into 'double'
 * @param String value//  w  w w .j  ava  2 s .  co  m
 * @return Integer
 */
public static double removeDoubleComma(String value) {
    return Double.parseDouble(value.replaceAll(",", ""));
}

From source file:Main.java

public static String unformatNumOrZero(String num) {
    try {//w ww  .  j  a v  a 2s . com
        num = num.replaceAll(",", "");
    } catch (Exception e) {
        return "0";
    }
    return num;
}

From source file:Main.java

public static String htmlDecode(String htmlStr) {
    String str = htmlStr;

    str = str.replaceAll("&", "&");
    str = str.replaceAll("'", "'");
    str = str.replaceAll("'", "'");
    str = str.replaceAll(""", "\"");
    str = str.replaceAll("&lt;", "<");
    str = str.replaceAll("&gt;", ">");

    return str;//w  w w . ja v  a2s  .  c  o  m
}

From source file:Main.java

public static String escape(String target) {
    String escape = target;
    escape = escape.replaceAll("&", "&amp;");
    escape = escape.replaceAll(">", "&gt;");
    escape = escape.replaceAll("<", "&lt;");
    escape = escape.replaceAll("\"", "&quot;");
    escape = escape.replaceAll("'", "&apos;");

    return escape;
}

From source file:Main.java

private static String unesc(String str) {
    return str.replaceAll("&&&", ":").replaceAll("&!&", "[").replaceAll("!&!", "]").replaceAll("!!!", ",")
            .replaceAll("!!&", "{").replaceAll("&&!", "}").replaceAll("###", "@");
}

From source file:Main.java

public static String splitCamelCase(String s) {
    return s.replaceAll(String.format("%s|%s|%s", "(?<=[A-Z])(?=[A-Z][a-z])", "(?<=[^A-Z])(?=[A-Z])",
            "(?<=[A-Za-z])(?=[^A-Za-z])"), " ");
}

From source file:Main.java

public static String constructFileName(String url) {
    return url.replaceAll("/", "_");
}

From source file:Main.java

public static String escape(String input) {
    return input.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"",
            "&quot");
}

From source file:Main.java

public static String reeplazarBackSlash(String ruta) {
    try {/*from w  w  w .  ja  v  a  2s  . c om*/
        return ruta.replaceAll("\\\\", "/");
    } catch (Exception exc) {
        return ruta;
    }
}