C# c中字符串中的GetDate#

C# c中字符串中的GetDate#,c#,string,datetime,C#,String,Datetime,我在使用正则表达式获取字符串中的日期时遇到了一些问题。 例如: string text = "75000+ Sept.-Oct. 2004"; MatchCollection dates = Regex.Matches(text, @"[0-9]{5,}[+][\s](jan|feb|fev|mar|apr|avr|may|mai|jun|jui|jul|jui|aug|aoû|sept|oct|nov|dec)[\.][\-](jan|feb|fev|mar|apr|avr|may|mai|

我在使用正则表达式获取字符串中的日期时遇到了一些问题。 例如:

 string text = "75000+ Sept.-Oct. 2004";
MatchCollection dates = Regex.Matches(text, @"[0-9]{5,}[+][\s](jan|feb|fev|mar|apr|avr|may|mai|jun|jui|jul|jui|aug|aoû|sept|oct|nov|dec)[\.][\-](jan|feb|fev|mar|apr|avr|may|mai|jun|jui|jul|jui|aug|aoû|sept|oct|nov|dec)[\.]\s[0-9]{4}", RegexOptions.IgnoreCase);
这段代码与我当前的字符串相匹配,但我想进入我的matchcollection“Sept 2004”和“Oct 2004”,以便在2 datetime中解析它


如果有人有任何想法,非常感谢。

检查阵列的长度等。你应该会有想法

 string text = "75000+ Sept.-Oct. 2004";
 MatchCollection dates = Regex.Matches(text, @"[0-9]{5,}[+][\s](jan|feb|fev|mar|apr|avr|may|mai|jun|jui|jul|jui|aug|aoû|sept|oct|nov|dec)[\.][\-](jan|feb|fev|mar|apr|avr|may|mai|jun|jui|jul|jui|aug|aoû|sept|oct|nov|dec)[\.]\s([0-9]{4})", RegexOptions.IgnoreCase);
 Console.WriteLine(dates[0].Groups[1] + " " + dates[0].Groups[3]);
 Console.WriteLine(dates[0].Groups[2] + " " + dates[0].Groups[3]);

非常感谢,我不知道我能得到每组正则表达式。