@Test public void escapeChar() throws Exception { assertEquals(StringEscapeUtilities.escapeChar("abcdeaaaca\\aaa", 'a'), "\\abcde\\a\\a\\ac\\a\\a\\a\\a"); }
@NotNull public static String escapeChar(@NotNull final String string, final char toEscape) { final String toEscapeStr = String.valueOf(toEscape); return string.replaceAll("\\\\" + toEscapeStr, toEscapeStr).replaceAll(toEscapeStr, "\\\\" + toEscapeStr); }
StringEscapeUtilities extends StringEscapeUtils { @NotNull public static String escapeChar(@NotNull final String string, final char toEscape) { final String toEscapeStr = String.valueOf(toEscape); return string.replaceAll("\\\\" + toEscapeStr, toEscapeStr).replaceAll(toEscapeStr, "\\\\" + toEscapeStr); } }
StringEscapeUtilities extends StringEscapeUtils { @NotNull public static String escapeChar(@NotNull final String string, final char toEscape) { final String toEscapeStr = String.valueOf(toEscape); return string.replaceAll("\\\\" + toEscapeStr, toEscapeStr).replaceAll(toEscapeStr, "\\\\" + toEscapeStr); } private  StringEscapeUtilities(); }
StringEscapeUtilities extends StringEscapeUtils { @NotNull public static String escapeChar(@NotNull final String string, final char toEscape) { final String toEscapeStr = String.valueOf(toEscape); return string.replaceAll("\\\\" + toEscapeStr, toEscapeStr).replaceAll(toEscapeStr, "\\\\" + toEscapeStr); } private  StringEscapeUtilities(); @NotNull static String escapeChar(@NotNull final String string, final char toEscape); @NotNull static String unescapeChar(@NotNull final String string, final char toUnescape); @NotNull static String escapeChars(@NotNull final String string, final char[] toEscape); @NotNull static String unescapeChars(@NotNull final String string, final char[] toUnescape); @NotNull static String removeEscapedChar(@NotNull final String string, final char toRemove); @NotNull static String removeEscapedChars(@NotNull final String string, final char[] toRemove); }
StringEscapeUtilities extends StringEscapeUtils { @NotNull public static String escapeChar(@NotNull final String string, final char toEscape) { final String toEscapeStr = String.valueOf(toEscape); return string.replaceAll("\\\\" + toEscapeStr, toEscapeStr).replaceAll(toEscapeStr, "\\\\" + toEscapeStr); } private  StringEscapeUtilities(); @NotNull static String escapeChar(@NotNull final String string, final char toEscape); @NotNull static String unescapeChar(@NotNull final String string, final char toUnescape); @NotNull static String escapeChars(@NotNull final String string, final char[] toEscape); @NotNull static String unescapeChars(@NotNull final String string, final char[] toUnescape); @NotNull static String removeEscapedChar(@NotNull final String string, final char toRemove); @NotNull static String removeEscapedChars(@NotNull final String string, final char[] toRemove);  }