List of usage examples for java.lang String replaceAll
public String replaceAll(String regex, String replacement)
From source file:Main.java
public static String getPowerNumberString(String string) { String Current = string.replaceAll(" ", ""); char[] chars = Current.toCharArray(); String number = ""; for (int i = 8; i < chars.length - 4; i++) { number += chars[i];//from w w w. j a v a 2 s . co m } return number; }
From source file:Main.java
public static String xmlEncode(String str) { return str.replaceAll("&", "&").replaceAll("<", "<").replaceAll("<", ">") .replaceAll("\"", """).replaceAll("'", "'"); }
From source file:Main.java
/** * Toglie placeholder e spazi all'inizio e alla fine. * * @param s valore da normalizzare/*from w w w. j a v a 2 s .c o m*/ * @return valore normalizzato */ public static String normalize(String s) { String s1 = s.replaceAll("_*$", ""); return s1.trim(); }
From source file:Main.java
/** * Converts a XHTML compliant id (used in jspx) to a CSS3 selector spec compliant id. In that * it will replace all '.,:,-' to '_'//ww w . ja va 2s.c o m * * @param proposed Id * @return cleaned up Id */ public static String convertId(String proposed) { return proposed.replaceAll("[:\\.-]", "_"); }
From source file:Main.java
public static String unescapeXml(String str) { str = str.replaceAll("&", "&"); str = str.replaceAll("<", "<"); str = str.replaceAll(">", ">"); str = str.replaceAll(""", "\""); str = str.replaceAll("'", "'"); return str;//from ww w . j a va2 s . c om }
From source file:Main.java
public static String decodeApostrophes(String value) { value = value.replaceAll("'", "'"); value = value.replaceAll("'", "'"); value = value.replaceAll("'", "'"); return value; }
From source file:Main.java
public static int getWordCount(String content) { String text = Html.fromHtml(content.replaceAll("<img[^>]*>", "")).toString(); return text.split("\\s+").length; }
From source file:Main.java
public static String removeLeadingZeroes(String num) { String regex = "^0*"; return num.replaceAll(regex, ""); }
From source file:Main.java
public static String deleteSpecialCharactersInString(String stringToAdapt) { return stringToAdapt.replaceAll("[\"*/:<>?\\\\|]", ""); }
From source file:Main.java
/** * <p>Effectively un-escapes a string, performs the reverse of {@link #escapeString(String)}.</p> * * @param text//from w w w. jav a 2s . c o m * @return {@link String} */ public static String unescapeString(String text) { String unescaped = text.replaceAll("\\\\n", "\n"); unescaped = unescaped.replaceAll("\\\\N", "\n"); unescaped = unescaped.replaceAll("\\\\\\\\", "\\\\"); unescaped = unescaped.replaceAll("\\\\,", ","); unescaped = unescaped.replaceAll("\\\\;", ";"); unescaped = unescaped.replaceAll("\\\\:", ":"); return unescaped; }