List of utility methods to do String Replace
String | replaceSpace(String str) replace Space if (str == null) { return str; return str.replace(" ", ""); |
String | replaceStr(String number) replace Str if ("".equals(number) || number == null) { return "0"; } else { return number; |
String | replaceString(String s, Map replace String if (s != null && !s.equals("") && replacement != null) { for (String key : replacement.keySet()) { String actualKey = "\\{" + key.toUpperCase(Locale.US) + "\\}"; s = s.replaceAll(actualKey, replacement.get(key)); return s; ... |
String | replaceWords(String src, String targetValue, String newValue) replace Words if (targetValue.equals("")) { throw new IllegalArgumentException( "Old pattern must have content."); StringBuffer result = new StringBuffer(); int startIdx = 0; int idxOld = src.indexOf(targetValue, startIdx); if (idxOld >= 0) { ... |
String | replaceWordsAll(String src, String targetValue, String newValue) replace Words All if (targetValue.equals("")) { throw new IllegalArgumentException( "Old pattern must have content."); StringBuffer result = new StringBuffer(); int startIdx = 0; int idxOld = 0; while ((idxOld = src.indexOf(targetValue, startIdx)) >= 0) { ... |
String | replaceBlank(String str) replace Blank String dest = ""; if (str != null) { str = str.replace(" ", "+"); Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); return dest; ... |
String | replaceBlank(String str) replace Blank String dest = ""; if (str != null) { Pattern p = Pattern.compile("\r"); Matcher m = p.matcher(str); dest = m.replaceAll(""); return dest; |
String | replaceBlank(String str) replace Blank String dest = ""; if (str != null) { Pattern p = Pattern.compile("\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); return dest; |
String | replaceBlank(String str) replace Blank Pattern pattern = Pattern.compile("\\s*|\t|\r|\n"); Matcher matcher = pattern.matcher(str); return matcher.replaceAll(""); |
String | removeIllegal(String input) remove Illegal String invalidXMLChars = "[^[\\u0009\\u000A\\u000D][\\u0020-\\uD7FF][\\uE000-\\uFFFD][\\u10000-\\u10FFFF]]"; return input.replaceAll(invalidXMLChars, "?"); |