code: private static String modify(final String str, final String[] set, final boolean expect) {
          final CharSet chars = CharSet.getInstance(set);
          final StringBuilder buffer = new StringBuilder(str.length());
          final char[] chrs = str.toCharArray();
          for (final char chr : chrs) {
              if (chars.contains(chr) == expect) {
                  buffer.append(chr);
              }
          }
          return buffer.toString();
      }
docs: Implementation of delete and keep
  
  @param str String to modify characters within
  @param set String[] set of characters to modify
  @param expect whether to evaluate on match, or non-match
  @return the modified String, not null