日期:2014-05-17 浏览次数:20531 次
string pattern = @"(?i)(['""]?)red\1:\s*?\[(?:(['""]?)(?<red>[^'""\],]+?)\2[,,]?\s*?)+[\s\S]*?latest_draw_phase\s*?=\s*?'([^']+?)'[\s\S]*?latest_draw_time\s*?=\s*?'([^']+?)'"; string tempStr = File.ReadAllText(@"C:\Users\M\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));//读取文档 Match _m=Regex.Match(tempStr,pattern); var result = new { red=string.Join(" ",_m.Groups["red"].Captures.Cast<Capture>().Select(a=>a.Value)), latest_draw_phase=_m.Groups[3].Value, latest_draw_time = _m.Groups[4].Value, }; /* * latest_draw_phase "201225727" string latest_draw_time "2012-09-20 15:45:00" string red "14 03 01 04 08" string */