question: 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 ( ) ; }
target:  Strips the apple span appended by WebKit while generating the selection markup.