RFR: 8305486: Add split() variants that keep the delimiters to String and j.u.r.Pattern [v2]

Roger Riggs rriggs at openjdk.org
Tue Apr 11 20:45:35 UTC 2023


On Tue, 11 Apr 2023 08:58:36 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/String.java line 3302:
>> 
>>> 3300:      * <tr><!-- o -->
>>> 3301:      *     <th scope="row" style="font-weight:normal; text-align:right; padding-right:1em">0</th>
>>> 3302:      *     <td>{@code { "b", "o", "", "o", ":::and::f", "o", "", "o" }}</td></tr>
>> 
>> These cases might be a bit easier to understand if the regex matched characters that looked more like delimiters, perhaps just ":".
>
> The choice of multi-character delimiter is deliberate, to show that the regex really absorbs all the delimiter characters.
> The `":+"` examples are followed by the `"o"` examples, where the delimiters are single characters.

I understood the value of `:+` case.
I found reading the single "o" as a delimiter is not intuitive or easy to parse because it looks like the the strings that are being delimited, not a delimiter.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13305#discussion_r1163308998


More information about the core-libs-dev mailing list