List of usage examples for java.lang String replaceAll
public String replaceAll(String regex, String replacement)
From source file:Main.java
public static String getLargeAvatar(String source) { if (source == null) return null; return source.replaceAll(AVATAR_SIZE_REG, LARGE_SIZE); }
From source file:Main.java
public static String unEscape(String s) { if (s == null) { return s; }//ww w .ja v a 2 s.co m return s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("'", "'") .replaceAll(""", "\""); }
From source file:com.threewks.thundr.googleapis.prediction.PredictionDataHelper.java
public static int countNewlines(String string) { return string == null ? 0 : string.replaceAll("[^\\n]", "").length(); }
From source file:Main.java
/** * Convert instances of a newline in a string to '\n'. * This is particularly necessary when creating a CDATA node from Windows, as the newline separator on this * platform is "\r\n", which (unbelievably) is serialized to "\r\r\n" as a "feature"! Of course, when this is * read back in, it is converted to "\n\n", meaning that the text was converted from single to double spaced. * To guard against this, all instances of "\r\n" and "\r" are converted to "\n". * @param stringToConvert the string to convert. * @return the converted string.// w w w . j av a2 s .c om */ private static String convertNewLines(String stringToConvert) { return stringToConvert.replaceAll("\r\n", "\n").replaceAll("\r", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ }
From source file:Main.java
public static String basename(String path) { if (path == null) return ""; path = path.replaceAll("/+$", ""); int i = path.lastIndexOf('/'); return (path.isEmpty()) ? "/" : (i == -1) ? path : path.substring(i + 1); }
From source file:com.threewks.thundr.googleapis.prediction.PredictionDataHelper.java
public static String normaliseWhitespace(String string) { return string == null ? "" : string.replaceAll("\\s+", " "); }
From source file:com.threewks.thundr.googleapis.prediction.PredictionDataHelper.java
public static String normalisePunctuationToSpaces(String string) { return string == null ? "" : string.replaceAll("\\p{Punct}", " "); }
From source file:Main.java
public static int parseColorFromString(String str, String defColorWithoutSymbols) { str.replaceAll("\\s+", ""); // Remove all spaces if (str.equals("")) { str = defColorWithoutSymbols;/*from w ww . j a v a 2 s. c o m*/ } if (!str.startsWith("#")) { str = "#" + str; } try { return Color.parseColor(str); } catch (Exception e) { return Color.parseColor("#" + defColorWithoutSymbols); } }
From source file:Main.java
public static String StringEscape(String str) { String cov = ""; if (str != null) { cov = str.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"); }/*w ww . j av a2 s . c o m*/ return cov; }
From source file:derpatiel.progressivediff.util.TextHelper.java
public static String getFormattedText(String string) { return string.replaceAll("&", "\u00A7"); }