Upgrade Regex with a tester() method?

Paul Sandoz paul.sandoz at oracle.com
Mon Jan 21 01:19:14 PST 2013


On Jan 19, 2013, at 3:58 AM, Ben Evans <benjamin.john.evans at gmail.com> wrote:

> Hi Brian,
> 
> The other possible point lambdafication for java.util.regex that I've
> come up with is
> 
> Pattern::splitAsStream
> 
> Stream<CharSequence> splitAsStream(CharSequence input)
> 
> Returns a stream consisting of the input sequence split around matches
> of this pattern.
> 
> What do people think of that as an idea?
> 

I like it. Implementation-wise this requires an Iterator over the matches.

One could do:

  splitAsStream(input).limit(10);

But it is tricker to the "remove all empty strings at the end" as supported by the split that takes a limit parameter of a 0 value.

Paul.


More information about the lambda-dev mailing list