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 urlDecodeForPathParams(String s) {
    s = s.replaceAll("\\+", "%2b");
    return urlDecode(s);
}

From source file:Main.java

public static String encode(String s) {
    if (s == null || s.equals("")) {
        return "";
    }/*w ww .  j a  va2s .  c  o  m*/
    String r = s;
    r = r.replaceAll("&", "&");
    r = r.replaceAll(">", ">");
    r = r.replaceAll("<", "&lt;");
    r = r.replaceAll("\"", "&quot;");
    r = r.replaceAll("'", "&apos;");
    return r;
}

From source file:Main.java

private static String makeLegalFilename(String filename, String extension) {
    return filename.replaceAll("[^a-zA-Z0-9' &\\.\\-]", "_").trim() + "." + extension;
}

From source file:Main.java

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

From source file:Main.java

public static String toAttrValue(String s) {
    return "\"" + (s == null ? "" : s.replaceAll("\"", "\\\\\"")) + "\"";
}

From source file:com.chiorichan.util.PermissionUtil.java

public static String removeInvalidChars(String ref) {
    return ref.replaceAll("[^a-z0-9_]", "");
}

From source file:Main.java

private static String removeSpaces(String string) {
    string = string.replaceAll("\\s+", "");
    return string;
}

From source file:Main.java

/**
 * removing comma and parse into 'int'//w  ww.j a v a  2  s.  c o  m
 * @param String value
 * @return Integer
 */
public static int removeIntegerComma(String value) {
    return Integer.parseInt(value.replaceAll(",", ""));
}

From source file:Main.java

/**
 * Adds escaping. Used for file paths./*w  w w  .j  a  va 2  s  .  c o  m*/
 *
 * @param input Input command line param
 * @return input string with escaped characters
 */
public static String getCommandLineString(String input) {
    return input.replaceAll(UNIX_ESCAPE_EXPRESSION, "\\\\$1");
}

From source file:Main.java

public static String getClassName(String signature) {
    String clsName = signature.replaceAll("/", ".");
    if (clsName.charAt(0) == 'L' && clsName.charAt(clsName.length() - 1) == ';') {
        return clsName.substring(1, clsName.length() - 1);
    }/*from   w  ww  .  j  a va2  s .  co m*/
    return clsName;
}