Re: read number from a string

From: William F. Robertson, Jr. (theman_at_nameht.org)
Date: 02/17/05


Date: Thu, 17 Feb 2005 13:22:07 -0600

You could use the split operator then test for ints.

string s = "TEST_1_str1, TEST_100_str2, TEST_1010_str3, TEST"
string [] sa = s.Split( '_' );

sa is a string array that contains the following information

sa[0] = "TEST"
sa[1] = "1"
sa[2] = "str1, TEST"
sa[3] = "100"
sa[4] = "str2, TEST"
...

You would step through each item in the array and check to see if it is an
int.

bill

"JIM.H." <JIMH@discussions.microsoft.com> wrote in message
news:6F60738F-F3DA-4781-9213-BA426A32CAD6@microsoft.com...
> Hello,
> I have TEST_1_str1, TEST_100_str2, TEST_1010_str3, TEST is fixed, how
could
> you read 1, 100, 1010 between _ from these kind of strings?
> Thanks,
> Jim.
>