简单实例:
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/webkaifa/) string s = "2005-2-21";
Regex reg = new Regex(@"(?yd{4})-(?md{1,2})-(?dd{1,2})",RegexOptions.Compiled);
Match match = reg.Match(s);
int year = int.Parse(match.Groups["y"].Value);
int month = int.Parse(match.Groups["m"].Value);
int day = int .Parse(match.Groups["d"].Value);
DateTime time = new DateTime(year,month,day);