代码: 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…
跟java里的split函数的用法是很相像的,举例如下: The awk function split(s,a,sep) splits a string s into an awk array a using the delimiter sep. set time = 12:34:56set hr = `echo $time | awk '{split($0,a,":" ); print a[1]}'` # = 12set sec = `echo $time | awk '{split…
在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…