在java doc里有 String[] java.lang.String.split(String regex) Splits this string around matches of the given regular expression. This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Tra…
代码: String str = "the music made it hard to concentrate"; String delims = "[ ]+"; String[] tokens = str.split(delims); 结果为: the, music, made, it, hard, to, concentrate 原因: String.split(String regex):参数是一个正则表达式 转自:http://pages.cs.wisc.e…