ISSUE :
 
Profile photo
Submitted by Piyushkumar Joshi
on February 28th, 2012 at 13:33:12 EST

Split Six digit numeric value from a sentence

I have a alphanumeric sentence starting with a six digit number. I need to separate/split that six digit number from the sentence. There is a mix of Alpha nad numbers in the entire sentence.

For example: 123456 Mr. Williums, 330514 Lovebird Lane, Phoenix. phone: 333-4444, Fax: 313-4141

I want the six digit numbers such as "123456" splitted.

Please help.


Profile photo
Replied by SBajra
on February 29th, 2012 at 07:49:24 EST
I am not sure how flexible solution you are look for but you can simply use substring() to get the first 6 digit from sentence.


string text = "123456 Mr. Williums, 330514 Lovebird Lane, Phoenix. phone: 333-4444, Fax: 313-4141";
string firstSixDigits = text.Substring(0, 6);


If you want more sophisticated solution then you can use regular expression.
Accepted Answer
Accepted
 Answer