Looking for the best way to parse a phone number (in a 3-3-4 format) from a string..
The string may contain a lot of junk information on the line.
If there is a code following the phone number then I also want to pick that up.
How can I handle these cases using regular expressions?
And if you have a better, more efficient way of parsing this information I am up for suggestions, as well.
I would like to store the phone number in one string, phone number with country in the same string if country code exists, and the --- should be stored in a seperate string such as in example 3.
Thanks in advance.
The string may contain a lot of junk information on the line.
If there is a code following the phone number then I also want to pick that up.
Code:
For example String1 = "This is string 1 and here is my phone number 123-456-7890" String2 = "String 2 is 123-456-7890USA" String3 = "String 3 may be 123-456-789 ---"
And if you have a better, more efficient way of parsing this information I am up for suggestions, as well.
I would like to store the phone number in one string, phone number with country in the same string if country code exists, and the --- should be stored in a seperate string such as in example 3.
Thanks in advance.