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 indent(String s) {
    return new StringBuilder(s.replaceAll("\n", "\n\t")).insert(0, "\t").toString();
}

From source file:Main.java

public static boolean isMacAddressAllZore(String addr) {
    String source = new String(addr);
    String str = source.replaceAll(":", "0");
    String[] splits = str.split("0");

    return splits.length == 0;
}

From source file:Main.java

public static byte[] hexStringToByteArray(final String byteString) {
    String value = byteString.replaceAll("[^A-Za-z0-9]", "");
    int len = value.length();
    byte[] data = new byte[len / 2];
    for (int i = 0; i < len; i += 2) {
        data[i / 2] = (byte) ((Character.digit(value.charAt(i), 16) << 4)
                + Character.digit(value.charAt(i + 1), 16));
    }/*from   w  w  w . j  a  v  a2s.c om*/
    return data;
}

From source file:Main.java

private static String decodeXML(String escapedXML) {
    String decodedXML = escapedXML;
    decodedXML = decodedXML.replaceAll("&lt;", "<");
    decodedXML = decodedXML.replaceAll("&gt;", ">");
    decodedXML = decodedXML.replaceAll("&quot;", "\"");
    decodedXML = decodedXML.replaceAll("&apos;", "'");
    decodedXML = decodedXML.replaceAll("&amp;", "&");
    return decodedXML;
}

From source file:Main.java

/**
 * format a string as a MAC address/* ww w.j  a  va 2  s . c o  m*/
 * 
 * @param address
 *            String containing at least 12 hexadecimal values
 * @return well formed MAC address
 */
public static String prepareMACAddress(String str) {
    String address = str.replaceAll("[^a-fA-F0-9]", "").toLowerCase();
    if (address.length() < 12)
        return null;
    String[] marr = address.split("");
    address = "";
    int i;
    for (i = 1; i < 10; i = i + 2)
        address += marr[i] + marr[i + 1] + ":";
    address += marr[i] + marr[i + 1];
    return address;
}

From source file:Main.java

public static String fixSmiles(String Smiles) {
    Smiles = Smiles.replaceAll("CL", "Cl");
    Smiles = Smiles.replaceAll("(H)", "([H])");
    //      Smiles=Smiles.replace("N=N#N","N=[N+]=[N-]");
    //      Smiles=Smiles.replace("#N=O","#[N+][O-]");
    Smiles = Smiles.trim();//from www  . ja  v  a  2  s .c o  m

    return Smiles;

}

From source file:Main.java

public static String getAppVersion(Context context) {
    PackageInfo pInfo = null;//from  w  w  w  . j a  v  a  2  s  . c o m
    try {
        pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    String version = pInfo.versionName;
    version.replaceAll(" ", "");
    return version;

}

From source file:com.hangum.tadpole.rdb.core.editors.main.SQLTextUtil.java

/**
 * ?  ??   ./*  w  w w.j  av  a  2s. c  o m*/
 * 
 * @param query
 * @return
 */
public static String delLineChar(String query) {
    return query.replaceAll("(\r\n|\n|\r)", "");
}

From source file:Main.java

public static String replaceAll(String source, String regex, String replacement) {
    return source.replaceAll(regex, replacement);
}

From source file:Main.java

public static String newRandomUUID() {
    String uuidRaw = UUID.randomUUID().toString();
    return uuidRaw.replaceAll("-", "");
}