The[m]/pattern/[i][m][s][x]
m
prefix is optional and the meaning of the optional trailing options are: The limit parameter causes the string to be split on at most the first limit - 1 number of pattern occurences.
Of special note is that this split method performs EXACTLY the same as the Perl split() function. In other words, if the split pattern contains parentheses, additional Vector elements are created from each of the matching subgroups in the pattern. Using an example similar to the one from the Camel book:
produces the Vector containing:split(list, "/([,-])/", "8-12,15,18")
The {@link org.apache.oro.text.regex.Util#split Util.split()} methoddoes NOT implement this particular behavior because it is intended to be usable with Pattern instances other than Perl5Pattern.{ "8", "-", "12", ",", "15", ",", "18" }
@param results A List
to which the substrings of the input that occur between the regular expression delimiter occurences are appended. The input will not be split into any more substrings than the specified limit. A way of thinking of this is that only the first limit - 1 matches of the delimiting regular expression will be used to split the input.
@param pattern The regular expression to use as a split delimiter.
@param input The String to split.
@param limit The limit on the size of the returned Vector
.Values <= 0 produce the same behavior as the SPLIT_ALL constant which causes the limit to be ignored and splits to be performed on all occurrences of the pattern. You should use the SPLIT_ALL constant to achieve this behavior instead of relying on the default behavior associated with non-positive limit values.
@exception MalformedPerl5PatternException If there is an error inthe expression. You are not forced to catch this exception because it is derived from RuntimeException.
|
|