Suppose we have a string like A.K. Ramaswamy
And we want to write the regular expression for the same. The below will do so
using System;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var input = "A.K. Ramaswamy";
Regex rgx = new Regex(@"^[a-zA-Z. ]*$");
Console.WriteLine(rgx.IsMatch(input));
Console.ReadKey();
}
}
}