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:de.atomfrede.tools.evalutation.util.PreProcessor.java

public static void replaceWhiteSpacesWithComma(File inputFile) throws IOException {
    List<String> inputLines = FileUtils.readLines(inputFile);
    List<String> outputlines = new ArrayList<String>();
    for (String line : inputLines) {
        String outLine = line.replaceAll("\\s+", ",");
        outLine += "\n";
        outputlines.add(outLine);/*  ww  w  .  j a  v  a 2s  .c  o m*/
    }
    int line = 0;
    for (String outputLine : outputlines) {
        if (line == 0)
            FileUtils.writeStringToFile(inputFile, outputLine, false);
        else
            FileUtils.writeStringToFile(inputFile, outputLine, true);
        line++;

    }
}

From source file:eu.trentorise.smartcampus.mobility.processor.alerts.DelayChecker.java

private static String getTrainNumericId(String id) {
    return id.replaceAll("\\D*", "");
}

From source file:Main.java

/**
 * Cleanup title. Remove from title file extension and (...), [...]
 *//*from w ww . j  av a 2s  . c om*/
public static String cleanupTitle(final String in) {
    String out = in;
    try {
        out = in.substring(0, in.lastIndexOf('.'));
        out = out.replaceAll("\\(.*?\\)|\\[.*?\\]", "").replaceAll("_", " ").replaceAll(".fb2$", "").trim();
    } catch (final IndexOutOfBoundsException e) {
    }
    return out;
}

From source file:Main.java

/**
 *
 * @param mobile/*from  w w w .j  a  va2s. co m*/
 * @return
 */
public static String formatMobileNumber(String mobile) {
    if (TextUtils.isEmpty(mobile)) {
        return "";
    }
    return mobile.replaceAll("[\\.\\-\\ ]", "").trim();
}

From source file:com.CodeSeance.JSeance.CodeGenXML.XMLElements.Text.java

public static String escapeXMLAttribute(String text) {
    return text.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;")
            .replaceAll("\n", "&#xA;").replaceAll("\r", "&#xD;").replaceAll("\u0009", "&#x9;");
}

From source file:com.google.demo.translate.Translator.java

private static String preTranslationParser(String string) {
    String result = string;

    result = result.replaceAll("&", "and");
    result = result.replaceAll("\"", "");

    return result;
}

From source file:de.snertlab.xdccBee.irc.DccMessageParser.java

private static String delete_control_codes(String packetName) {
    String s = packetName;
    s = s.replaceAll("\\002|\\003(\\d{1,2})?(,\\d{1,2})?|\\x0F|\\x16|\\x1F", "");
    s = StringUtils.trim(s);// w w w.j  a  va 2s .co m
    return s;
}

From source file:Main.java

public static String QspStrToHtml(String str) {
    String result = "";
    if (str != null && str.length() > 0) {
        str = str.replaceAll("\r", "<br>");
        //          str = str.replaceAll("(?i)</td>", " ");
        //          str = str.replaceAll("(?i)</tr>", "<br>");
        //          result = Html.fromHtml(str, imgGetter, null);
        result = str;/*from w  w w .  j  a  va2  s  .c  o m*/
    }
    return result;
}

From source file:Main.java

private static String getResourceName(String resourceName) {
    String rn = new String(resourceName.substring(0, 1).toLowerCase() + resourceName.substring(1));
    rn = rn.replaceAll(" ", "");
    for (int i = 'A'; i <= 'Z'; i++) {
        char ch = (char) i;
        String s = new String(ch + "");
        rn = rn.replaceAll(s, "_" + s.toLowerCase());
    }//from  w ww .  jav  a 2  s.  c  o m
    return rn;
}