public static String cropBetween(String in,String limit){
  StringBuilder out=new StringBuilder();
  int lastPos=0;
  int lenLimit=limit.length();
  boolean modeAdd=true;
  int pos=-1;
  while ((pos=in.indexOf(limit,lastPos)) >= 0) {
    if (modeAdd) {
      out.append(in.substring(lastPos,pos));
    }
    modeAdd=!modeAdd;
    lastPos=pos + lenLimit;
  }
  if (modeAdd) {
    out.append(in.substring(lastPos));
  }
  return out.toString();
}

public static String cropBetween ( String in , String limit ) { StringBuilder out = new StringBuilder ( ) ; int lastPos = 0 ; int lenLimit = limit . length ( ) ; boolean modeAdd = true ; int pos = - 1 ; while ( ( pos = in . indexOf ( limit , lastPos ) ) >= 0 ) { if ( modeAdd ) { out . append ( in . substring ( lastPos , pos ) ) ; } modeAdd = ! modeAdd ; lastPos = pos + lenLimit ; } if ( modeAdd ) { out . append ( in . substring ( lastPos ) ) ; } return out . toString ( ) ; }
this removes characters between maching charlimit chars . for example cropbetween ( " ab ^ cd ^ ef ^ gh ^ hi " , ' ^ ' ) will return " abefhi " it will consider squences of 2 charlimit as one charlimit in the output
