jdk/src/share/classes/java/util/regex/Pattern.java
changeset 21670 ca3553133ede
parent 21668 b62ce4a9635f
child 22078 bdec5d53e98c
equal deleted inserted replaced
21669:582457f85c7b 21670:ca3553133ede
  1142      * input sequence that is terminated by another subsequence that matches
  1142      * input sequence that is terminated by another subsequence that matches
  1143      * this pattern or is terminated by the end of the input sequence.  The
  1143      * this pattern or is terminated by the end of the input sequence.  The
  1144      * substrings in the array are in the order in which they occur in the
  1144      * substrings in the array are in the order in which they occur in the
  1145      * input. If this pattern does not match any subsequence of the input then
  1145      * input. If this pattern does not match any subsequence of the input then
  1146      * the resulting array has just one element, namely the input sequence in
  1146      * the resulting array has just one element, namely the input sequence in
  1147      * string form. A zero-length input sequence always results zero-length
  1147      * string form.
  1148      * resulting array.
       
  1149      *
  1148      *
  1150      * <p> When there is a positive-width match at the beginning of the input
  1149      * <p> When there is a positive-width match at the beginning of the input
  1151      * sequence then an empty leading substring is included at the beginning
  1150      * sequence then an empty leading substring is included at the beginning
  1152      * of the resulting array. A zero-width match at the beginning however
  1151      * of the resulting array. A zero-width match at the beginning however
  1153      * never produces such empty leading substring.
  1152      * never produces such empty leading substring.
  1199      *
  1198      *
  1200      * @return  The array of strings computed by splitting the input
  1199      * @return  The array of strings computed by splitting the input
  1201      *          around matches of this pattern
  1200      *          around matches of this pattern
  1202      */
  1201      */
  1203     public String[] split(CharSequence input, int limit) {
  1202     public String[] split(CharSequence input, int limit) {
  1204         if (input.length() == 0)
       
  1205             return new String[0];
       
  1206         int index = 0;
  1203         int index = 0;
  1207         boolean matchLimited = limit > 0;
  1204         boolean matchLimited = limit > 0;
  1208         ArrayList<String> matchList = new ArrayList<>();
  1205         ArrayList<String> matchList = new ArrayList<>();
  1209         Matcher m = matcher(input);
  1206         Matcher m = matcher(input);
  1210 
  1207 
  5765      *
  5762      *
  5766      * <p> The stream returned by this method contains each substring of the
  5763      * <p> The stream returned by this method contains each substring of the
  5767      * input sequence that is terminated by another subsequence that matches
  5764      * input sequence that is terminated by another subsequence that matches
  5768      * this pattern or is terminated by the end of the input sequence.  The
  5765      * this pattern or is terminated by the end of the input sequence.  The
  5769      * substrings in the stream are in the order in which they occur in the
  5766      * substrings in the stream are in the order in which they occur in the
  5770      * input.  Trailing empty strings will be discarded and not encountered in
  5767      * input. Trailing empty strings will be discarded and not encountered in
  5771      * the stream.
  5768      * the stream.
  5772      *
  5769      *
  5773      * <p> If this pattern does not match any subsequence of the input then
  5770      * <p> If this pattern does not match any subsequence of the input then
  5774      * the resulting stream has just one element, namely the input sequence in
  5771      * the resulting stream has just one element, namely the input sequence in
  5775      * string form.
  5772      * string form.
  5776      *
       
  5777      * <p> A zero-length input sequence always results an empty stream.
       
  5778      *
  5773      *
  5779      * <p> When there is a positive-width match at the beginning of the input
  5774      * <p> When there is a positive-width match at the beginning of the input
  5780      * sequence then an empty leading substring is included at the beginning
  5775      * sequence then an empty leading substring is included at the beginning
  5781      * of the stream. A zero-width match at the beginning however never produces
  5776      * of the stream. A zero-width match at the beginning however never produces
  5782      * such empty leading substring.
  5777      * such empty leading substring.