Name: nt126004 Date: 08/29/2001
The specification of the Pattern#split limit argument doesn't match Perl and
misses the whole point of the limit. According to
http://java.sun.com/j2se/1.4/docs/api/java/util/regex/Pattern.html
The input "boo:and:foo", for example, yields the following results with these
parameters:
Regex Limit Result
: 2 { "boo", "and" }
But this is *not* what Perl's split does, and misses the
whole point of the "limit" argument. The perl program
perl -le 'print join("|", split(" ", "boo:and:foo", 2))'
prints
boo and:foo
*not*
boo and
The point of the "limit" argument is to limit the number
of times the pattern is applied, so that, e.g., only the
first ':' is treated as a separator. But the Java version
doesn't provide this functionality.
(Review ID: 130770)
======================================================================
- duplicates
-
JDK-4497806 Java split methods work differently from Perl split methods
-
- Closed
-