List of utility methods to do String Replace
String | replace(String from, String to, String source) replace if (source == null || source.length() == 0 || from == null || from.length() == 0 || to == null) { return source; StringBuffer str = new StringBuffer(""); int index = -1; int len = from.length(); while ((index = source.indexOf(from)) != -1) { ... |
String | replace(String line, String oldString, String newString) replace if (line == null) { return null; int i = 0; if ((i = line.indexOf(oldString, i)) >= 0) { char[] line2 = line.toCharArray(); char[] newString2 = newString.toCharArray(); int oLength = oldString.length(); ... |
String | replace(String originalString, String searchString, String replaceString) replace StringBuilder sb = new StringBuilder(originalString); int index = sb.indexOf(searchString); while (index != -1) { sb.replace(index, index + searchString.length(), replaceString); index += replaceString.length(); index = sb.indexOf(searchString, index); return sb.toString(); ... |
String | replace(String str, Map replace Matcher matcher = REPLACE_PATTERN.matcher(str); StringBuilder builder = new StringBuilder(); int i = 0; while (matcher.find()) { Object replacement = replacementMap.get(matcher.group(2)); builder.append(str.substring(i, matcher.start() == 0 ? 0 : matcher.start() + 1)); builder.append(replacement != null ? replacement : ""); ... |
String | replace(final String text, final String fromText, final String toText) replace if (text == null || fromText == null || toText == null) { return null; StringBuffer buf = new StringBuffer(100); int pos = 0; int pos2 = 0; while (true) { pos = text.indexOf(fromText, pos2); ... |
String | replaceAll(String input, String searchStr, String replaceWithStr) replace All StringBuffer buffer = new StringBuffer(); int startIndex = 0; int oldIndex = 0; if (input.indexOf(searchStr) == -1) { return input; while ((startIndex = input.indexOf(searchStr, oldIndex)) != -1) { buffer.append(input.substring(oldIndex, startIndex)); ... |
String | replaceAllKanaWith(String text, String replacement) replace All Kana With return text.replaceAll("[\u3040-\u3096]", replacement); |
String | replaceAllKanjiWith(String text, String replacement) replace All Kanji With return text.replaceAll("[\u4e00-\u9faf]", replacement); |
StringBuilder | replaceKeyWords(StringBuilder sb, String[] keywords, String replaceStr) replace Key Words for (int i = 0; i < keywords.length; i++) { String s = keywords[i]; for (int j = sb.indexOf(s); j > 0; j = sb.indexOf(s)) { sb.replace(j, j + s.length(), replaceStr); return sb; |
String[] | replaceR(String str) replace R String[] s = { "", "" }; String strReturn = ""; if (str.indexOf("\r\n") != -1) { s[1] = "\r\n"; s[0] = str.replaceAll("\r\n", ""); return s; } else if (str.indexOf("\n") != -1) { s[1] = "\n"; ... |