private int findWordEnd(String text,int pos){
  int end=-1;
  Matcher m=WORD.matcher(text);
  if (pos > 0) {
    pos--;
  }
  if (m.find(pos)) {
    end=m.end();
  }
  if (text.length() == pos) {
    end=text.length();
  }
  if (end == -1) {
    end=text.length();
  }
  return end;
}

private int findWordEnd ( String text , int pos ) { int end = - 1 ; Matcher m = WORD . matcher ( text ) ; if ( pos > 0 ) { pos -- ; } if ( m . find ( pos ) ) { end = m . end ( ) ; } if ( text . length ( ) == pos ) { end = text . length ( ) ; } if ( end == - 1 ) { end = text . length ( ) ; } return end ; }
find the end of the word at the given position .
