Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Splitting strings

Reply
Thread Tools

Splitting strings

 
 
davidjohnlong@googlemail.com
Guest
Posts: n/a
 
      03-30-2006
Hi

Wondered if anyone can help

I'm trying to split the following string into various different
section?

BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
2*Cream,2*Vanilla,*,*,2*Whisky

after : first varible
then 2nd, 3rd, 4th 5th after comma

(trying in impliment RFC 2324... )

Thanks

 
Reply With Quote
 
 
 
 
Alex Hunsley
Guest
Posts: n/a
 
      03-30-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi
>
> Wondered if anyone can help
>
> I'm trying to split the following string into various different
> section?
>
> BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
> 2*Cream,2*Vanilla,*,*,2*Whisky
>
> after : first varible
> then 2nd, 3rd, 4th 5th after comma
>
> (trying in impliment RFC 2324... )
>
> Thanks


Use StringTokenizer.
http://java.sun.com/j2se/1.4.2/docs/...Tokenizer.html

This sort of question is more suited to comp.lang.java.help as it's a
simple question. Also you could have tried googling for "java string
splitting" or similar, which would probably have given you the answer.
 
Reply With Quote
 
 
 
 
IchBin
Guest
Posts: n/a
 
      03-30-2006
Alex Hunsley wrote:
> (E-Mail Removed) wrote:
>> Hi
>>
>> Wondered if anyone can help
>>
>> I'm trying to split the following string into various different
>> section?
>>
>> BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
>> 2*Cream,2*Vanilla,*,*,2*Whisky
>>
>> after : first varible
>> then 2nd, 3rd, 4th 5th after comma
>>
>> (trying in impliment RFC 2324... )
>>
>> Thanks

>
> Use StringTokenizer.
> http://java.sun.com/j2se/1.4.2/docs/...Tokenizer.html
>
> This sort of question is more suited to comp.lang.java.help as it's a
> simple question. Also you could have tried googling for "java string
> splitting" or similar, which would probably have given you the answer.


Or take a look at String Class Split(). I think Sun is moving away from
StringTokenizer.

String[] stringVar.split(String regex) Splits this string around
matches of the given regular expression.

String[] stringVar.split(String regex, int limit) Splits this string
around matches of the given regular expression.

Then you use the the new 1.5 The For-Each Loop.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________ ________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      03-30-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi
>
> Wondered if anyone can help
>
> I'm trying to split the following string into various different
> section?
>
> BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
> 2*Cream,2*Vanilla,*,*,2*Whisky
>
> after : first varible
> then 2nd, 3rd, 4th 5th after comma
>
> (trying in impliment RFC 2324... )


Are you expecting the the above as one long string? Note that the ':'
appears twice in it.

I'd expect some newline characters to be present, as in:

<2324 request>
BREW coffee://localhost/pot-1
HTCPCP/0.1
accept-additions: 2*Cream,2*Vanilla,*,*,2*Whisky
</2324 request>

- Oliver

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
splitting strings in midlets leni Java 3 08-07-2005 04:27 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? John Dibling C++ 0 07-19-2003 04:41 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? Mark C++ 0 07-19-2003 04:24 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? John Ericson C++ 0 07-19-2003 04:03 PM



Advertisments