Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38508

Re: "less for more" - a little story about String.split

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From Andreas Leitgeb <avl@logic.at>
Newsgroups comp.lang.java.programmer
Subject Re: "less for more" - a little story about String.split
Date Sat, 28 Jul 2018 13:04:07 -0000 (UTC)
Organization A noiseless patient Spider
Lines 15
Message-ID <slrnploqe7.e93.avl@logic.at> (permalink)
References <slrnpllf5d.e93.avl@logic.at> <5b5bbee9.431171906@news.xmission.com>
Reply-To avl@logic.at
Injection-Date Sat, 28 Jul 2018 13:04:07 -0000 (UTC)
Injection-Info reader02.eternal-september.org; posting-host="895f93563094bc9ae1ccf56c7306f0f3"; logging-data="20595"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+AnWwMWMGnZaM4kyi1DKz"
User-Agent slrn/1.0.3 (Linux)
Cancel-Lock sha1:/2oT4eNyOA1hM4FAtLovAM+vYks=
Xref csiph.com comp.lang.java.programmer:38508

Show key headers only | View raw


Scott <nobody@example.org> wrote:
> The implied exception seems to be that the above does not apply to a
> string that contains no matching delimiters, which is simply returned
> as-is, even if it's empty.

That's essentially the gist of my story.

Documentation specifies that for a limit of 0, trailing empty strings are
discarded from result, but in implementation this is restricted to cases
where the pattern matches at least once.

The behaviour I'd really prefer would be if at least one (possibly empty)
element would be always retained - also in the case where the delimiter
does have a match.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

"less for more" - a little story about String.split Andreas Leitgeb <avl@logic.at> - 2018-07-27 06:33 +0000
  Re: "less for more" - a little story about String.split nobody@example.org (Scott) - 2018-07-28 01:16 +0000
    Re: "less for more" - a little story about String.split Andreas Leitgeb <avl@logic.at> - 2018-07-28 13:04 +0000

csiph-web