Splitting strings

D

davidjohnlong

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
 
A

Alex Hunsley

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/api/java/util/StringTokenizer.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.
 
I

IchBin

Alex said:
Use StringTokenizer.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.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-)
 
O

Oliver Wong

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top