111,126
社区成员
发帖
与我相关
我的任务
分享
string source = "2012年10月";
Regex reg = new Regex(@"(?<year>\d{4}).*(?<month>(0[1-9]|1[0-2])).*");
Match mm = reg.Match(source);
MessageBox.Show(mm.Groups["year"].Value);
MessageBox.Show(mm.Groups["month"].Value);
string source = "2012年10月";
string source1 = source.Substring(0, source.IndexOf("年"));
string source2 = source.Substring(source.IndexOf("年") + 1, source.IndexOf("月") - source.IndexOf("年") - 1);
string source = "2012年6月";
Regex reg = new Regex(@"(?<year>\d{4}).*(?<month>\d{1,2}).*");
Match mm = reg.Match(source);
MessageBox.Show(mm.Groups["year"].Value);
MessageBox.Show(mm.Groups["month"].Value);