Closed JobGetabu closed 6 years ago
Hey @JobGetabu ,
Am looking at this Regex, and what it implies is that the phone number can contain a comma, eg +2547,24587654
.
Use this site to test your regex
This issue can be resolved through this sample
static void Main(string[] args)
{
string phoneNumberList = "+25472487654";
//string phoneNumberList = "+25472487654,+254734587654,+25471587654";
string[] nums = phoneNumberList.Split(','); // Split comma separated values
foreach (string num in nums)
{
Console.WriteLine(num);
Console.WriteLine(IsPhoneNumber(num));
}
Console.ReadLine();
}
private static bool IsPhoneNumber(string number)
{
return Regex.Match(number, @"^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d$").Success && number.Length > 5;
}
[EDIT]
static void Main(string[] args)
{
bool status = false;
bool stat = true;
//string phoneNumberList = "+4654";
string phoneNumberList = "+25472487654,+25473487654,+25471587654,+4654";
string[] nums = phoneNumberList.Split(',');
foreach (string num in nums)
{
Console.WriteLine(num);
status = IsPhoneNumber(num);
Console.WriteLine(status);
stat = stat & status;
}
Console.WriteLine("Overall: " +stat);
Console.ReadLine();
}
private static bool IsPhoneNumber(string number)
{
return Regex.Match(number, @"^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d{5,}$").Success;
}
line: 185 Update to IsPhoneNumber(string number) Regex.Match to accept comma separated numbers +254708440184 :true +254708440184,+254708440184,+254708440184 :true +254708440184, :false +254708440184,+254708440184,+254708440184, :false