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 ConvertOnlyNumerical(String input) {
    String output = input.replaceAll("[^0-9]", "");
    //String output=input.replaceAll("^[^0-9]+$", "");
    return output;
}

From source file:Main.java

public static String getSimpleUrl(String url) {
    String simpleUrl = url.replaceAll("\\?.*", "");
    return simpleUrl;
}

From source file:Main.java

/**
 * Fix html currency symbols to the unicode equivalent
 * /*from  w ww.j  a v  a 2s .  c o  m*/
 * @param string
 * @return
 */
public static String currencyFix(final String string) {
    return string.replaceAll("£", "\u00A3").replaceAll("€", "\u20AC");
}

From source file:Main.java

public static String fixForUserInput(String str) {
    str = str.replaceAll("\\@<B>", "<B>@");
    return str;//from   www.j a v  a2s.  c o  m
}

From source file:Main.java

private static String trimVersion(String s) {
    return s.replaceAll("[^0-9.]", "");
}

From source file:Main.java

public static String toXPathExper(String simplePath) {
    simplePath = simplePath.replaceAll("/([^/]+)", "/\\*[local-name()='$1']");
    simplePath = simplePath.replaceAll("^/", "//");
    return simplePath;
}

From source file:Main.java

/**
 * adds a tab to every line/*w w w.  j av a  2s  .c  o m*/
 * 
 * @param text
 * @return
 */
public static String addTab(String text) {
    return text.replaceAll("\n", "\n\t");
}

From source file:Main.java

/**
 * So hacky I don't want to think about it.
 * //w ww .  j  a v  a  2s  .  c  o m
 * Takes in the xml text (as a string), 
 * looks for a specific phrase ("xmlnsCHANGEME") and modifies
 * it such that it looks right when it comes time to displaying it
 * 
 * 
 * @param namespaceURI
 * @return
 */
public static String setDataNodeXMLNS(String xmlString) {
    return xmlString.replaceAll("xmlnsCHANGEME", "xmlns");
}

From source file:Main.java

public static String formatContent(String content) {
    content = content.replaceAll("&([^#])", "&amp;$1");
    content = content.replaceAll("<", "&lt;");
    content = content.replaceAll(">", "&gt;");
    content = content.replaceAll("\"", "&quot;");
    content = content.replaceAll("'", "&#39;");
    return content;
}

From source file:Main.java

public static String entitizeContent(String xml) {
    return xml.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
}