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

Raffaello Giulietti rgiulietti at openjdk.org
Tue Apr 11 09:05:50 UTC 2023


On Mon, 10 Apr 2023 14:35:06 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8305486: Add split() variants that keep the delimiters to String and j.u.r.Pattern
>>   Restored original JavaDoc to existing methods.
>>   Replaced proposed parametrized split(*, boolean) methods with suggested splitWithDelimiters(*) variants.
>>   Adjusted tests accordingly.
>
> 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.

> src/java.base/share/classes/java/lang/String.java line 3324:
> 
>> 3322:      *         the result threshold, as described above
>> 3323:      *
>> 3324:      * @return  the array of strings computed by splitting this string
> 
> Add a mention to the delimiters in the result.

Done.

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

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


More information about the core-libs-dev mailing list