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:com.skcraft.launcher.builder.BuilderUtils.java

public static String normalizePath(String path) {
    return path.replaceAll("^[/\\\\]*", "").replaceAll("[/\\\\]+", "/");
}

From source file:edu.harvard.i2b2.crc.util.StringUtil.java

public static String escapeORACLE(String sql) {

    sql = sql.replaceAll("\\?", "??");
    sql = sql.replaceAll("_", "?_");
    sql = sql.replaceAll("%", "?%");
    //     sql += "%";
    return sql;/*from  w  w  w.j av  a2  s .co m*/
}

From source file:Main.java

/**
 * Convert a string number into a double value
 *
 * @param text the text to be converted to number
 * @return the double value/*from   ww w .j ava 2  s  .c o  m*/
 */
private static double stringToDouble(String text) {

    text = text.replaceAll(",", ".");
    NumberFormat nf = NumberFormat.getInstance(Locale.US);
    try {
        return nf.parse(text).doubleValue();
    } catch (ParseException e) {
        Log.e(TAG, e.getMessage(), e);
        return 0.0;
    }
}

From source file:Main.java

@SuppressWarnings("DynamicRegexReplaceableByCompiledPattern")
private static byte[] parseMachineId(String value) {
    // Strip separators.
    value = value.replaceAll("[:-]", "");

    byte[] machineId = new byte[MACHINE_ID_LEN];
    for (int i = 0; i < value.length(); i += 2) {
        machineId[i] = (byte) Integer.parseInt(value.substring(i, i + 2), 16);
    }//w  w w  .  j a v  a 2s  . co  m

    return machineId;
}

From source file:Main.java

public static String millisToStringFilename(long millis, String pattern) {
    String dateStr = millisToStringDate(millis, pattern);
    return dateStr.replaceAll("[- :]", "_");
}

From source file:com.bluexml.side.requirements.generator.services.StringEscapeUtilsService.java

public static String escapeHtml(EObject node, String label) {
    return StringEscapeUtils.escapeHtml(label.replaceAll("\n", "<br/>").replaceAll("\r", ""));
}

From source file:Main.java

public static String stripNumberFormatiing(String string) {

    if (string.contains("(")) {
        string = string.replaceAll("[^0-9]", "");
    }// w  w w. j a  v  a2 s  .  c o m
    return string;
}

From source file:Main.java

public static String fromSql(String sql) {
    if (sql == null)
        return "";
    sql = sql.replaceAll("''", "'");
    return sql;//from  w ww .  j a v  a2 s  .  c o m
}

From source file:Main.java

public static String toSql(String sql) {
    if (sql == null)
        return "";
    sql = sql.replaceAll("'", "''");
    return sql;/*from   www .  ja  va 2s .  c o m*/
}

From source file:com.hp.mqm.client.QueryHelper.java

private static String escapeQueryValue(String value) {
    return value.replaceAll("(\\\\)", "$1$1").replaceAll("([\"'])", "\\\\$1");
}