public static String[] split(Pattern pattern, String re, String input, int limit) { String[] fastResult = fastSplit(re, input, limit); if (fastResult != null) { return fastResult; } // Unlike Perl, which considers the result of splitting the empty string to be the empty // array, Java returns an array containing the empty string. if (input.isEmpty()) { return new String[] { "" }; } // Collect text preceding each occurrence of the separator, while there's enough space. ArrayList<String> list = new ArrayList<String>(); Matcher matcher = new Matcher(pattern, input); int begin = 0; while (list.size() + 1 != limit && matcher.find()) { list.add(input.substring(begin, matcher.start())); begin = matcher.end(); } return finishSplit(list, input, begin, limit); }
public static String[] split(Pattern pattern, String re, String input, int limit) { String[] fastResult = fastSplit(re, input, limit); if (fastResult != null) { return fastResult; } // Unlike Perl, which considers the result of splitting the empty string to be the empty // array, Java returns an array containing the empty string. if (input.isEmpty()) { return new String[] { "" }; } // Collect text preceding each occurrence of the separator, while there's enough space. ArrayList<String> list = new ArrayList<String>(); Matcher matcher = new Matcher(pattern, input); int begin = 0; while (list.size() + 1 != limit && matcher.find()) { list.add(input.substring(begin, matcher.start())); begin = matcher.end(); } return finishSplit(list, input, begin, limit); }
public static String[] split(Pattern pattern, String re, String input, int limit) { String[] fastResult = fastSplit(re, input, limit); if (fastResult != null) { return fastResult; } // Unlike Perl, which considers the result of splitting the empty string to be the empty // array, Java returns an array containing the empty string. if (input.isEmpty()) { return new String[] { "" }; } // Collect text preceding each occurrence of the separator, while there's enough space. ArrayList<String> list = new ArrayList<String>(); Matcher matcher = new Matcher(pattern, input); int begin = 0; while (list.size() + 1 != limit && matcher.find()) { list.add(input.substring(begin, matcher.start())); begin = matcher.end(); } return finishSplit(list, input, begin, limit); }
public static String[] split(Pattern pattern, String re, String input, int limit) { String[] fastResult = fastSplit(re, input, limit); if (fastResult != null) { return fastResult; } // Unlike Perl, which considers the result of splitting the empty string to be the empty // array, Java returns an array containing the empty string. if (input.isEmpty()) { return new String[] { "" }; } // Collect text preceding each occurrence of the separator, while there's enough space. ArrayList<String> list = new ArrayList<String>(); Matcher matcher = new Matcher(pattern, input); int begin = 0; while (list.size() + 1 != limit && matcher.find()) { list.add(input.substring(begin, matcher.start())); begin = matcher.end(); } return finishSplit(list, input, begin, limit); }
public static String[] split(Pattern pattern, String re, String input, int limit) { String[] fastResult = fastSplit(re, input, limit); if (fastResult != null) { return fastResult; } // Unlike Perl, which considers the result of splitting the empty string to be the empty // array, Java returns an array containing the empty string. if (input.isEmpty()) { return new String[] { "" }; } // Collect text preceding each occurrence of the separator, while there's enough space. ArrayList<String> list = new ArrayList<String>(); Matcher matcher = new Matcher(pattern, input); int begin = 0; while (list.size() + 1 != limit && matcher.find()) { list.add(input.substring(begin, matcher.start())); begin = matcher.end(); } return finishSplit(list, input, begin, limit); }
public static String[] split(Pattern pattern, String re, String input, int limit) { String[] fastResult = fastSplit(re, input, limit); if (fastResult != null) { return fastResult; } // Unlike Perl, which considers the result of splitting the empty string to be the empty // array, Java returns an array containing the empty string. if (input.isEmpty()) { return new String[] { "" }; } // Collect text preceding each occurrence of the separator, while there's enough space. ArrayList<String> list = new ArrayList<String>(); Matcher matcher = new Matcher(pattern, input); int begin = 0; while (list.size() + 1 != limit && matcher.find()) { list.add(input.substring(begin, matcher.start())); begin = matcher.end(); } return finishSplit(list, input, begin, limit); }
public static String[] split(Pattern pattern, String re, String input, int limit) { String[] fastResult = fastSplit(re, input, limit); if (fastResult != null) { return fastResult; } // Unlike Perl, which considers the result of splitting the empty string to be the empty // array, Java returns an array containing the empty string. if (input.isEmpty()) { return new String[] { "" }; } // Collect text preceding each occurrence of the separator, while there's enough space. ArrayList<String> list = new ArrayList<String>(); Matcher matcher = new Matcher(pattern, input); int begin = 0; while (list.size() + 1 != limit && matcher.find()) { list.add(input.substring(begin, matcher.start())); begin = matcher.end(); } return finishSplit(list, input, begin, limit); }