A Regular Expression to validate alphabetic characters with dots and spaces in C#

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 336
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();
}
}
}

Comments or Responses

Login to post response