private String getNextTag ( String str ) { String tag ; int endIndex ; int tagIndex = str . indexOf ( "(" ) ; if ( tagIndex < 0 ) { return null ; } // in case there's nothing in the sentence endIndex = str . indexOf ( " " , tagIndex ) ; if ( endIndex < 0 ) { return null ; } tag = str . substring ( tagIndex + 1 , endIndex ) ; if ( tag . length ( ) > 0 ) { return tag ; } else { str = str . substring ( tagIndex + 1 ) ; return getNextTag ( str ) ; } }
Returns the next tag in the sentence or null if there are no more tags