using System.Text.RegularExpressions;
///
///是否为日期型字符串
///
///
yyyy-MM-dd,严格按照规定
///
public static bool IsDate(string StrSource)
{
string[] arry = Regex.Split(StrSource, "-");
if (arry.Length != 3)
return false;
if (arry[0].Length != 4)
return false;
if (arry[1].Length != 2)
return false;
if (arry[2].Length != 2)
return false;
return Regex.IsMatch(StrSource, @"^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$");
}
///
/// 是否为时间型字符串
///
///
时间字符串(15:00:00)
///
public static bool IsTime(string StrSource)
{
return Regex.IsMatch(StrSource, @"^((20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d)$");
}