-
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!
-
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(",")) );
}