public static int getDelimIndex ( StringBuilder sb , int itemPos , char [ ] delims , boolean ignoreEmpty ) { if ( StringUtil . isEmpty ( sb ) ) return - 1 ; int curr = - 1 , listIndex = 0 ; int len = sb . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( contains ( delims , sb . charAt ( i ) ) ) { curr = i ; if ( ignoreEmpty ) { if ( i == 0 || ( i + 1 < len && contains ( delims , sb . charAt ( i + 1 ) ) ) ) { sb . delete ( curr , curr + 1 ) ; len -- ; i -- ; curr -- ; continue ; } } if ( ++ listIndex == itemPos ) break ; } } if ( listIndex < itemPos ) return len ; return curr ; }
returns the 0 - based delimiter position for the specified item