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 cleanTorrentName(String torrentName) {
    return torrentName.replaceAll("[_\\.\\-\\|]", " ").replaceAll("( +)", " ").replaceAll("[^a-zA-Z0-9 ]", "");
}

From source file:Main.java

/**
 * replaceSpace in the url// w w  w  .ja  va2s.c om
 * 
 * @param url
 * @return
 */
public static String replaceSpace(String url) {
    return url.replaceAll(" ", "%20");
}

From source file:Main.java

public static String getFilenameFromBSSID(final String BSSID) {
    return BSSID.replaceAll(":", "_");
}

From source file:Main.java

/**
 * Escape XML//  w  ww.  j  a v a2s.co m
 * @param str The string
 * @return The string as valid XML
 */
public static String escapeXML(String str) {
    return str.replaceAll("\"", "&quot;").replaceAll("&", "&amp;").replaceAll("<", "&lt;")
            .replaceAll(">", "&gt;").replaceAll("'", "&apos;");
}

From source file:Main.java

private static String flattenXML(String s) {
    String flatS = s.replaceAll("> *<([^/])", "><$1").replaceAll("\n", "");
    return flatS;
}

From source file:Main.java

public static String escapeUnescapedCharacters(String str) {
    String txt = str.replaceAll("&", "&amp;");
    return txt;//w  w w .j av  a2s.c  o m
}

From source file:Main.java

/**
 * Converts the ampersand, quote, prime, less-than and greater-than
 * characters to their corresponding HTML entities in the given string.
 *//* www . j  ava 2 s . c  o  m*/
public static String htmlEntities(String text) {
    return text.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("'", "&prime;")
            .replaceAll("<", "&lt;").replaceAll(">", "&gt;");
}

From source file:Main.java

private static String colonize(String orig) {
    return orig.replaceAll("(?<=..)(..)", ":$1");
}

From source file:Main.java

/**
 * Return Primary Account Number with a space between each digit group.
 *
 * @param pan String//www  .  ja va  2s . c o m
 * @return    String
 */
public static String prettyPan(String pan) {
    return pan.replaceAll("(.{4}(?!$))", "$1 ").trim();
}

From source file:Main.java

public static String entify(String s) {
    s = s.replaceAll("<", "&lt;");
    s = s.replaceAll(">", "&gt;");
    s = s.replaceAll("&", "&amp;");
    return s;//from   w  w w .ja  va2  s  .c  o  m
}