Code example for BreakIterator

Methods: lastprevioussetText

0
 
  @Override 
  public int findStartOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 1 ) return start;
    bi.setText(buffer.substring(0, start));
    bi.last();
    return bi.previous();
  } 
 
  @Override 
  public int findEndOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 0 ) return start;
    bi.setText(buffer.substring(start));
    return bi.next() + start;
  } 
}