@Test @DisplayName("Method escape throws an exception when escape char is at the last position") void testEscapeAtLastPosition() { assertThatThrownBy(() -> Escape.escape("wuff \\")) .isInstanceOf(IllegalArgumentException.class); }
static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); } }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }  }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }   }
Escape { static String escape(String original) { final var sb = new StringBuilder(original); final var output = new StringBuilder(); final var ignored = new StringBuilder(); while (sb.length() > 0) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output, ignored); } else { output.append(ch); sb.deleteCharAt(0); } } return output.toString(); }    }