List of usage examples for java.lang String replace
public String replace(CharSequence target, CharSequence replacement)
From source file:Main.java
public static String unescapeXML(String xml) { // TODO: this is incorrect and inefficient return xml.replace("<", "<").replace(">", ">").replace("&", "&"); }
From source file:Main.java
public static String escapeRegexp(String s) { String[] esc = { "\\", ".", "*", "[", "]", "(", ")", "|", "?", "$", "^" }; String result = s; for (String escChar : esc) result = result.replace(escChar, "\\" + escChar); return result; }
From source file:Main.java
public static Bundle parseUrl(String url) { url = url.replace("#", "?"); try {//www . j a v a 2s .c o m URL u = new URL(url); Bundle b = decodeUrl(u.getQuery()); Bundle ref = decodeUrl(u.getRef()); if (ref != null) b.putAll(ref); return b; } catch (MalformedURLException e) { return new Bundle(); } }
From source file:Main.java
public static String deparseText(String text) { if (text.contains(TAG_OPEN)) { return text.replace(TAG_OPEN, "").replace(TAG_CLOSE, ""); }/*from w ww. j av a 2 s. c om*/ return text; }
From source file:Main.java
public static String formatPhoneNumber(String phone) { if (phone != null) { phone = phone.replace("+", "00"); phone = phone.replaceAll("[^\\d]", ""); phone = phone.replace(" ", ""); } else {// w w w . ja v a 2 s . c o m phone = ""; } return phone; }
From source file:Main.java
public static String escapeAttribute(String attribute, boolean escapeEntities) { if (attribute == null) return ""; String ret = attribute; if (escapeEntities) ret = ret.replace("&", "&"); return ret.replace("\"", """).replace("'", "'"); }
From source file:Main.java
public static String toIdableName(String xpath) { xpath = "X" + xpath; xpath = xpath.replace("/", "-"); xpath = xpath.replace("[", "_"); return xpath.replace("]", ":"); }
From source file:Main.java
public static String utf8Replace(String str) { if (str != null) { return str.replace(FULL_MINUS, HALF_MINUS); }/*from w ww.ja va 2 s . c o m*/ return null; }
From source file:Main.java
public static String escapeElementContent(String xmlContent, boolean escapeEntities) { if (xmlContent == null) return ""; String ret = xmlContent; if (escapeEntities) ret = ret.replace("&", "&"); return ret.replace("<", "<"); // There's no need to escape '>'. }
From source file:Main.java
public static String getAsAttribute(String attrName, String value) { if (value != null) { String val = value.replace("&", "&"); //val = val.replace("\"", """); val = val.replace("\"", "'"); val = val.replace("<", "<").replace(">", ">"); return " " + attrName + "=\"" + val + "\" "; } else {/*w w w.j a v a2 s . c om*/ return " " + attrName + "=\"\" "; } }