using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
Console.WriteLine("Enter your mobile number");
string mobileNumber = Console.ReadLine();
string MNregExp = @"^\+?\d{0,2}\-?\d{4,5}\-?\d{5,6}";
if (Regex.IsMatch(mobileNumber, MNregExp))
{
Console.WriteLine("Mobile number is in correct format");
}
else
{
Console.WriteLine("Mobile number is in incorrect format");
}
}
}
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
Console.WriteLine("Enter your mobile number");
string mobileNumber = Console.ReadLine();
string MNregExp = @"^\+?\d{0,2}\-?\d{4,5}\-?\d{5,6}";
if (Regex.IsMatch(mobileNumber, MNregExp))
{
Console.WriteLine("Mobile number is in correct format");
}
else
{
Console.WriteLine("Mobile number is in incorrect format");
}
}
}
No comments:
Post a Comment