先上源码:
/**
* Splits this string around matches of the given <a
* href="../util/regex/Pattern.html#sum">regular expression</a>.
*
* <p> This method works as if by invoking the two-argument {@link
* #split(String, int) split} method with the given expression and a limit
* argument of zero. Trailing empty strings are therefore not included in
* the resulting array.
*
* <p> The string {@code "boo:and:foo"}, for example, yields the following
* results with these expressions:
*
* <blockquote><table cellpadding=1 cellspacing=0 summary="Split examples showing regex and result">
* <tr>
* <th>Regex</th>
* <th>Result</th>
* </tr>
* <tr><td align=center>:</td>
* <td>{@code { "boo", "and", "foo" }}</td></tr>
* <tr><td align=center>o</td>
* <td>{@code { "b", "", ":and:f" }}</td></tr>
* </table></blockquote>
*
*
* @param regex
* the delimiting regular expression
*
* @return the array of strings computed by splitting this string
* around matches of the given regular expression
*
* @throws PatternSyntaxException
* if the regular expression's syntax is invalid
*
* @see java.util.regex.Pattern
*
* @since 1.4
* @spec JSR-51
*/
public String[] split(String regex) {
return split(regex, 0);
}
翻译注释为:
/ **
*围绕给定<a的匹配拆分此字符串
* href =“../ util / regex / Pattern.html#sum”>正则表达式</a>。
*
* <p>此方法就像调用双参数{@link一样
* #split(String,int)split}方法与给定的表达式和限制
*参数为零。因此,不包括尾随空字符串
*结果数组。
*
* <p>例如,字符串{@code“boo:and:foo”}产生以下结果
*这些表达式的结果:
*
* <blockquote> <table cellpadding = 1 cellspacing = 0 summary =“显示正则表达式和结果的拆分示例”>
* <tr>
* <th>正则表达式</ th>
* <th>结果</ th>
* </ tr>
* <tr> <td align = center>:</ td>
* <td> {@ code {“boo”,“and”,“foo”}} </ td> </ tr>
* <tr> <td align = center> o </ td>
* <td> {@ code {“b”,“”,“:and:f”}} </ td> </ tr>
* </ table> </ blockquote>
*
*
* @param正则表达式
*分隔正则表达式
*
* @return通过拆分此字符串计算的字符串数组
*围绕给定正则表达式的匹配
*
* @throws PatternSyntaxException
*如果正则表达式的语法无效
*
* @see java.util.regex.Pattern
*
* @since 1.4
* @spec JSR-51
* /