public static int findWordStart(CharSequence line,int pos,String noWordSep,boolean joinNonWordChars,boolean camelCasedWords,boolean eatWhitespace,boolean eatOnlyAfterWord){
  char ch=line.charAt(pos);
  if (noWordSep == null)   noWordSep="";
  int type=getCharType(ch,noWordSep);
  for (int i=pos; i >= 0; i--) {
    char lastCh=ch;
    ch=line.charAt(i);
switch (type) {
case WHITESPACE:
      if (Character.isWhitespace(ch))       break;
 else       if (!eatOnlyAfterWord) {
        return i + 1;
      }
 else       if (Character.isLetterOrDigit(ch) || noWordSep.indexOf(ch) != -1) {
        type=WORD_CHAR;
      }
 else       type=SYMBOL;
    break;
case WORD_CHAR:
  if (camelCasedWords && Character.isUpperCase(ch) && !Character.isUpperCase(lastCh)&& Character.isLetterOrDigit(lastCh)) {
    return i;
  }
 else   if (camelCasedWords && !Character.isUpperCase(ch) && Character.isUpperCase(lastCh)) {
    return i + 1;
  }
 else   if (Character.isLetterOrDigit(ch) || noWordSep.indexOf(ch) != -1) {
    break;
  }
 else   if (Character.isWhitespace(ch) && eatWhitespace && !eatOnlyAfterWord) {
    type=WHITESPACE;
    break;
  }
 else   return i + 1;
case SYMBOL:
if (!joinNonWordChars && pos != i) return i + 1;
if (Character.isWhitespace(ch)) {
if (eatWhitespace && !eatOnlyAfterWord) {
  type=WHITESPACE;
  break;
}
 else return i + 1;
}
 else if (Character.isLetterOrDigit(ch) || noWordSep.indexOf(ch) != -1) {
return i + 1;
}
 else {
break;
}
}
}
return 0;
}

public static int findWordStart ( CharSequence line , int pos , String noWordSep , boolean joinNonWordChars , boolean camelCasedWords , boolean eatWhitespace , boolean eatOnlyAfterWord ) { char ch = line . charAt ( pos ) ; if ( noWordSep == null ) noWordSep = "" ; int type = getCharType ( ch , noWordSep ) ; for ( int i = pos ; i >= 0 ; i -- ) { char lastCh = ch ; ch = line . charAt ( i ) ; switch ( type ) { case WHITESPACE : if ( Character . isWhitespace ( ch ) ) break ; else if ( ! eatOnlyAfterWord ) { return i + 1 ; } else if ( Character . isLetterOrDigit ( ch ) || noWordSep . indexOf ( ch ) != - 1 ) { type = WORD_CHAR ; } else type = SYMBOL ; break ; case WORD_CHAR : if ( camelCasedWords && Character . isUpperCase ( ch ) && ! Character . isUpperCase ( lastCh ) && Character . isLetterOrDigit ( lastCh ) ) { return i ; } else if ( camelCasedWords && ! Character . isUpperCase ( ch ) && Character . isUpperCase ( lastCh ) ) { return i + 1 ; } else if ( Character . isLetterOrDigit ( ch ) || noWordSep . indexOf ( ch ) != - 1 ) { break ; } else if ( Character . isWhitespace ( ch ) && eatWhitespace && ! eatOnlyAfterWord ) { type = WHITESPACE ; break ; } else return i + 1 ; case SYMBOL : if ( ! joinNonWordChars && pos != i ) return i + 1 ; if ( Character . isWhitespace ( ch ) ) { if ( eatWhitespace && ! eatOnlyAfterWord ) { type = WHITESPACE ; break ; } else return i + 1 ; } else if ( Character . isLetterOrDigit ( ch ) || noWordSep . indexOf ( ch ) != - 1 ) { return i + 1 ; } else { break ; } } } return 0 ; }
locates the start of the word at the specified position .
