private static String modify(String str,String[] set,boolean expect){
  CharSet chars=evaluateSet(set);
  StringBuffer buffer=new StringBuffer(str.length());
  char[] chrs=str.toCharArray();
  int sz=chrs.length;
  for (int i=0; i < sz; i++) {
    if (chars.contains(chrs[i]) == expect) {
      buffer.append(chrs[i]);
    }
  }
  return buffer.toString();
}

private static String modify ( String str , String [ ] set , boolean expect ) { CharSet chars = evaluateSet ( set ) ; StringBuffer buffer = new StringBuffer ( str . length ( ) ) ; char [ ] chrs = str . toCharArray ( ) ; int sz = chrs . length ; for ( int i = 0 ; i < sz ; i ++ ) { if ( chars . contains ( chrs [ i ] ) == expect ) { buffer . append ( chrs [ i ] ) ; } } return buffer . toString ( ) ; }
implementation of delete and keep
