Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb 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: References: <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 Scott 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.