public static bool IsDate(string strDate)
{
Regex reg = new Regex(@"((19|20)[0-9]{2})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])");
return reg.IsMatch(strDate);
}
可以判斷字符串是否是年月日格式,方法返回bool類型的true或false.
public static bool IsDate(string strDate)
{
Regex reg = new Regex(@"((19|20)[0-9]{2})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])");
return reg.IsMatch(strDate);
}
可以判斷字符串是否是年月日格式,方法返回bool類型的true或false.