RFR: JDK-8027645: Pattern.split() with positive lookahead
Xueming Shen
xueming.shen at oracle.com
Mon Nov 11 18:02:44 UTC 2013
On 11/11/2013 01:15 AM, Paul Sandoz wrote:
> On Nov 8, 2013, at 10:56 PM, Xueming Shen<xueming.shen at oracle.com> wrote:
>
>> On 11/08/2013 01:19 AM, Paul Sandoz wrote:
>>> Hi Sherman.
>>>
>>> When you say:
>>>
>>> + * of the stream. A zero-width match at the beginning however never produces
>>> + * such empty leading substring.
>>>
>>> Is it possible to have a starting sequence of one or more zero-width matches?
>> The matcher.find() always increases its "next find start position" at least one
>> as showed in Matcher.find() impl ("first" starts from -1), so the matcher.find()
>> should keep going forward, never produce more than one zero-length substring.
>>
> OK.
>
>
>> Matcher:
>> public boolean find() {
>> int nextSearchIndex = last;
>> if (nextSearchIndex == first)
>> nextSearchIndex++;
>> ...
>>
>> The webrev has been updated to use your optimized version in splitAsStream().
>>
>> http://cr.openjdk.java.net/~sherman/8027645/webrev/
> +1
>
> I still think it would be useful to add a comment at the relevant code location about zero-width match behaviour.
Thanks Paul!
I added two lines of comment as suggested.
http://cr.openjdk.java.net/~sherman/8027645/webrev
-Sherman
More information about the core-libs-dev
mailing list