Ok, thanks for everyone helping me so far, i have been working on this regex for quite some time. I got it working, but i'm thinking that their must be a simplier solution. i have a string that can look many ways, for example:
string telH = " asd833. 0000 cell ";
or
string telH = " 777 9999 C ";
I set a string telH to the numbers that could be in telH
so i'm actually looking to parse the 7 numbers out of the string and set it to the string telH, this is what i have
so if i have a string like so:
string telH = " 123 1234 cell"
the regex would yield
telHP = "123"
telHS = "1234"
How can this be accomplished, thanks
string telH = " asd833. 0000 cell ";
or
string telH = " 777 9999 C ";
I set a string telH to the numbers that could be in telH
so i'm actually looking to parse the 7 numbers out of the string and set it to the string telH, this is what i have
Code:
Match mymatch = Regex.Match(telH, @"\d{3}[^0-9]*?\d{4}", RegexOptions.None);
if (mymatch.Success)
{
telHP = mymatch.Value.Substring(0, 3);
telHS = mymatch.Value.Substring(mymatch.Length - 4, 4);
}
string telH = " 123 1234 cell"
the regex would yield
telHP = "123"
telHS = "1234"
How can this be accomplished, thanks