public static Vector < String > split ( String string , String regex ) { Vector < String > strings = new Vector < String > ( ) ; for ( String value : string . split ( new String ( regex ) ) ) { value = value . trim ( ) ; if ( ! value . equals ( "" ) ) { strings . add ( shrink ( value ) ) ; } } return strings ; }
Split the string into values using the regular expression removes whitespace from the beginning and end of the resultant strings and replaces runs of whitespace with a single space .