|
-
Dec 6th, 2004, 08:10 PM
#1
Thread Starter
PowerPoster
extracting strings
im having a problem and its frustrating
im trying to read entries from a text file, and extract just the city names
the format is something like this:
cityname, 213, 45, 7.5
cityname2, 7, 254, 12, 445
..
..
i cant seem to extract the text, the cityname properly. how do i go about extracting the cityname? remember - city names can have spaces inbetween them....i need to get it to from the start to the the first numeric number
thanks!
-
Dec 6th, 2004, 08:48 PM
#2
Frenzied Member
Re: extracting strings
Will the city name ever have a comma in it? If not, you could try using something like this
Code:
string strIn = "cityname, 213, 45, 7.5\n"+
"cityname2, 7, 254, 12, 445";
string[] strCities = strIn.Split('\n');
foreach ( string str in strCities )
{
MessageBox.Show( str.Substring(0,str.IndexOf(",")) );
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|