Srinivas,
I am sorry that the links that I provided did not help you. So I have
posted a code sample below to expand on the post that provided earlier. To
simplify the example I am using US date format and British date format to
validate against. To execute the example create a console application and
copy and paste the code below. Watch out for any line wrap. If you have any
questions please reply to this post.
I hope this helps!
--------------------------
using System;
using System.Collections;
using System.Globalization;
using System.Text.RegularExpressions;
namespace ResourceRegExpTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
//set up the Current Culture of this thread
string strCulture = CultureInfo.CurrentCulture.Name;
//set up the regular expressions associated with the culture (these are
for date
Hashtable CultRegExp = new Hashtable();
CultRegExp.Add("en-US",@"(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[-
/.](19|20)\d\d"); //English-US (mm/dd/yyyy)
CultRegExp.Add("en-GB",@"(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[-
/.](19|20)\d\d"); //English - United Kingdom (dd/mm/yyyy)
//get a date from the console input
Console.Write("Please enter a date: " );
string strDate = Console.ReadLine();
//get the current culture of the thread
if(CultRegExp.ContainsKey(strCulture))
if(Regex.IsMatch(strDate,CultRegExp[strCulture].ToString()))
Console.WriteLine("The string entered was a date match to the culture:
" + strCulture);
else
Console.WriteLine("The string entered was NOT a match to the culture: "
+ strCulture);
else
Console.WriteLine("There was no match in the hashtable for the culture:
" + strCulture);
}
}
}