// Pattern to split into words separated by spaces or commas, ignoring null fields // In other words, anything matching this pattern is considered a place to break words. private static Pattern splitter = Pattern.compile ("[, ]++" ); ... // Split phrase into words String[] words = splitter.split( phrase );