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


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

Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()?

Date 2011-08-25 22:31 -0400
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()?
References <4e55dd30$0$7613$9b4e6d93@newsspool1.arcor-online.net> <LuqdnQ3pFovJf8jTnZ2dnUVZ_uOdnZ2d@posted.palinacquisition>
Message-ID <4e57058a$0$312$14726298@news.sunsite.dk> (permalink)
Organization SunSITE.dk - Supporting Open source

Show all headers | View raw


On 8/25/2011 1:49 AM, Peter Duniho wrote:
> On 8/24/11 10:27 PM, Gunter Hansen wrote:
>> Assume I split a text line with a command like:
>>
>> String[] part = line.split("\\s+");
>>
>> Ok, fine, but how is the opposite command?
>> Keep in mind that the delimiter between the joined slots of the target
>> string should be one blank.
>>
>> Moreover: Can I join e.g. only slots [3],...,[MAX]?
>>
>> So I need a command similar to:
>>
>> String joined = part[3,MAX].join(' ');
>>
>> How ca I achieve this?
>>
>> If this is not possible directly then maxbe with a work around?
>
> I am surprised the feature doesn't exist in the JDK; in .NET there's a
> String.Join() method that does exactly what you're asking about. But
> AFAIK, it doesn't.

Even split was just added in 1.4 - before that it was StringTokenizer.

> And I have to admit, I think Java's take on the "split" function is
> pretty cool, what with regex support and all (which .NET doesn't
> provide, not as a String.Split() feature anyway).

.NET has Regex.Split.

Arne

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


Thread

How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? GHansen@hotmail.com (Gunter Hansen) - 2011-08-25 05:27 +0000
  Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-24 22:49 -0700
    回复:Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Yuxuan Wang <crnlmcn@gmail.com> - 2011-08-24 23:42 -0700
    Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Arne Vajhøj <arne@vajhoej.dk> - 2011-08-25 22:31 -0400
      Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-25 20:15 -0700
  Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Roedy Green <see_website@mindprod.com.invalid> - 2011-08-25 13:05 -0700
    Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Roedy Green <see_website@mindprod.com.invalid> - 2011-08-31 23:41 -0700
  Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Arne Vajhøj <arne@vajhoej.dk> - 2011-08-25 22:28 -0400

csiph-web