I have a multi line string text that has in each line a phone number joined by some text or spacial characters(characters not in English) so I want to check the text line by line and for each line extract the phone number and keep it in a rich text box I faced one problem and that is how to Remove any element other than numbers from character array .. any help !!
using(StringReader reader=new StringReader(richTextBox1.Text))
{
string line = string.Empty;
do
{
line = reader.ReadLine();
if (line != null)
{
// Checking if the line contains things other than letters
char[] buffer = line.Replace(" ", string.Empty).ToCharArray();
for (int i = 0; i < buffer.Length; i++)
{
if (!char.IsNumber(buffer[i]))
{
// Delete any letters or spacial characters
}
}
Regex rx = new Regex("^[730-9]{9}$");
if (rx.IsMatch(line))
{
richTextBox2.Text+=line;
}
}
} while (line != null);
}}