Tuesday, September 2, 2008

Validate String max length using Reguler Expression in C#

class Program
{
static void Main(string[] args)
{
if (Regex.IsMatch("[Input String]","^.{4,20}$" ))
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
}

No comments: