@Test public void replaceAllTest() { String sql = "select Price\nfrom products;"; String replace = StringUtils.replaceAll(sql, "\n", " "); Assert.assertEquals("select Price from products;", replace); sql = "select Price\rfrom products;"; replace = StringUtils.replaceAll(sql, "\r", " "); Assert.assertEquals("select Price from products;", replace); sql = "select Price\\from products;"; replace = StringUtils.replaceAll(sql, "\\", "\\\\"); Assert.assertEquals("select Price\\\\from products;", replace); }
public static String replaceAll(final String str, final String replace, final String replacement) { final StringMaker sb = stringMakerFactory.newString(str); int firstOccurrence = sb.toString().indexOf(replace); while (firstOccurrence != -1) { sb.replace(firstOccurrence, firstOccurrence + replace.length(), replacement); final int position = firstOccurrence + replacement.length(); firstOccurrence = sb.toString().indexOf(replace, position); } return sb.toString(); }
StringUtils { public static String replaceAll(final String str, final String replace, final String replacement) { final StringMaker sb = stringMakerFactory.newString(str); int firstOccurrence = sb.toString().indexOf(replace); while (firstOccurrence != -1) { sb.replace(firstOccurrence, firstOccurrence + replace.length(), replacement); final int position = firstOccurrence + replacement.length(); firstOccurrence = sb.toString().indexOf(replace, position); } return sb.toString(); } }
StringUtils { public static String replaceAll(final String str, final String replace, final String replacement) { final StringMaker sb = stringMakerFactory.newString(str); int firstOccurrence = sb.toString().indexOf(replace); while (firstOccurrence != -1) { sb.replace(firstOccurrence, firstOccurrence + replace.length(), replacement); final int position = firstOccurrence + replacement.length(); firstOccurrence = sb.toString().indexOf(replace, position); } return sb.toString(); } private  StringUtils(); }
StringUtils { public static String replaceAll(final String str, final String replace, final String replacement) { final StringMaker sb = stringMakerFactory.newString(str); int firstOccurrence = sb.toString().indexOf(replace); while (firstOccurrence != -1) { sb.replace(firstOccurrence, firstOccurrence + replace.length(), replacement); final int position = firstOccurrence + replacement.length(); firstOccurrence = sb.toString().indexOf(replace, position); } return sb.toString(); } private  StringUtils(); static String padRight(final String s, final int n); static String padRight(final String start, final String s, final int n); static String replaceAll(final String str, final String replace, final String replacement); static String removePart(final String str, final String start, final String end); static String removePart(final String str, final String start, final String end, final String exception); static int beginPart(final String str, final String start, final String end, final String exception,
			final int first); }
StringUtils { public static String replaceAll(final String str, final String replace, final String replacement) { final StringMaker sb = stringMakerFactory.newString(str); int firstOccurrence = sb.toString().indexOf(replace); while (firstOccurrence != -1) { sb.replace(firstOccurrence, firstOccurrence + replace.length(), replacement); final int position = firstOccurrence + replacement.length(); firstOccurrence = sb.toString().indexOf(replace, position); } return sb.toString(); } private  StringUtils(); static String padRight(final String s, final int n); static String padRight(final String start, final String s, final int n); static String replaceAll(final String str, final String replace, final String replacement); static String removePart(final String str, final String start, final String end); static String removePart(final String str, final String start, final String end, final String exception); static int beginPart(final String str, final String start, final String end, final String exception,
			final int first);  }