110,533
社区成员
发帖
与我相关
我的任务
分享
string[] dd = new string[] { "12 3 17", "09 12 12", "12 12 3", "11 9 3", "12 3 18" };
string[] txtdata = File.ReadAllLines(@"C:\1.txt", System.Text.Encoding.GetEncoding("GB2312"));
Dictionary<string, int> listdic= new Dictionary<string, int>();
foreach (string s in txtdata)
{
foreach (Match m in Regex.Matches(s, @"\d+ (\d{2} \d{1,2} \d{1,2})"))
{
for (int k = 0; k < dd.Length; k++)
{
int i = 0;
if (m.Groups[1].Value.Equals(dd[k]))
{
i = k;
listdic.Add(s, i);//结果
}
}
}
}