// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");
using System.Text.RegularExpressions;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter an email address:");
var email = Console.ReadLine();
Console.WriteLine("Enter mobile number:");
var mobile = Console.ReadLine();
var mobilePattern = "^[6-9]\\d{9}$";
if (Regex.IsMatch(mobile, mobilePattern)) {
Console.WriteLine("Valid mobile number");
} else {
Console.WriteLine("Invalid mobile number");
}
var pattern = "^[a-zA-Z0-9._%/+-]+@[a-zA-Z0-9.-]+[a-zA-Z]{2,}$";
if(Regex.IsMatch(email, pattern)) {
Console.WriteLine("Valid email address");
} else {
Console.WriteLine("Invalid email address");
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter