Searching way to assign blank delimited strings to different variables?

G

Gianni Galore

Assume I read text lines from a file.
Each line consists of blank delimited tokens (strings) similar to e.g.

2011.02.26 Hello Karl ID=42542-;OWE comment455###

At first this line is read into a string variable "myline";

Now I want to assign all the parts to different (string) variables e.g. an array of Strings.
The delimiter should be one or more blanks/whitespaces. The result should be like

part[0]=2011.02.26
part[1]=Hello
part[2]=Karl
part[3]=ID=42542-;OWE
part[4]=comment455###

How can I do this most easily?

Advanced question: Is there a way to DIRECTLY access the let say 3rd token WITHOUT previous split+assign?
Something like:

String thirdtok=gettoken(myline,3);

Gianni
 

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,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top