Split string by whitespace

Wirloff

Member
Joined
Mar 2, 2005
Messages
19
Location
Belgium
Programming Experience
1-3
Hi,
I have to read the text from a txtfile into a database. I know how to manage all the connections, but the only problem is:
How do you split a line by his whitespace?

ex (these are all phonecalls):
1/12/04_09:23:45___myName ___calledNumber

if I have tried spacePostion = theString.IndexOf(" ") en then use string.substring(startPosition, spacePosition) and so long, and I manage to get the date correctly from it.... but it doesn't work when there are 2 or more spaces between the info...
Any idea's how to solve this???
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Split it into an array using .split(" ") and then trim it to make sure there's no extra spaces.

TPM
 
Top Bottom