private static String stripAppleSpanFromMarkup(String markup){
  StringBuilder stripped=new StringBuilder(markup);
  int prefixBegIdx=stripped.indexOf(APPLE_SPAN_PREFIX);
  while (prefixBegIdx >= 0) {
    int prefixEndIdx=stripped.indexOf(">",prefixBegIdx) + 1;
    stripped.replace(prefixBegIdx,prefixEndIdx,"");
    int suffixBegIdx=stripped.lastIndexOf(APPLE_SPAN_SUFFIX);
    int suffixEndIdx=suffixBegIdx + APPLE_SPAN_SUFFIX.length();
    stripped.replace(suffixBegIdx,suffixEndIdx,"");
    prefixBegIdx=stripped.indexOf(APPLE_SPAN_PREFIX);
  }
  return stripped.toString();
}

private static String stripAppleSpanFromMarkup ( String markup ) { StringBuilder stripped = new StringBuilder ( markup ) ; int prefixBegIdx = stripped . indexOf ( APPLE_SPAN_PREFIX ) ; while ( prefixBegIdx >= 0 ) { int prefixEndIdx = stripped . indexOf ( ">" , prefixBegIdx ) + 1 ; stripped . replace ( prefixBegIdx , prefixEndIdx , "" ) ; int suffixBegIdx = stripped . lastIndexOf ( APPLE_SPAN_SUFFIX ) ; int suffixEndIdx = suffixBegIdx + APPLE_SPAN_SUFFIX . length ( ) ; stripped . replace ( suffixBegIdx , suffixEndIdx , "" ) ; prefixBegIdx = stripped . indexOf ( APPLE_SPAN_PREFIX ) ; } return stripped . toString ( ) ; }
strips the apple span appended by webkit while generating the selection markup .
