/** * Escapes all the occurrences of the <toEscape> characters from the <string> if they are not escaped already * * @param string the string from which to escape the characters * @param toEscape the characters to escape as Array * @return a new string with the escaped <toEscape> characters */ @NotNull public static String escapeChars(@NotNull final String string, final char[] toEscape) { String toReturn = string; for (char character : toEscape) { toReturn = escapeChar(toReturn, character); } return toReturn; }
/** * Escapes all the occurrences of the <toEscape> characters from the <string> if they are not escaped already * * @param string the string from which to escape the characters * @param toEscape the characters to escape as Array * @return a new string with the escaped <toEscape> characters */ @NotNull public static String escapeChars(@NotNull final String string, final char[] toEscape) { String toReturn = string; for (char character : toEscape) { toReturn = escapeChar(toReturn, character); } return toReturn; }