0

我有以下日志文​​件

    10:12:28.571 INFO INFO McEvent (ExitWaitPostProcess) Stage: 2 
    10:12:28.571 INFO McReplay:StatusEvent: 0C0000004576656E74496E666F207631260000000A000000484C4D494E464F207631C0A80A0100007F0000010000010100000000000100000046658FDC5008000000303331333030303115000000
    5761697420666F7220706F73742070726F636573735E00000045786974205761697420666F7220706F73742070726F63657373205374616765204E6F322C20592D617869732846726F6E742053696465292C202852656172204C616E65292C205043422049443A20202020202020202020202020202020
    10:12:28.571 INFO McReplay:StatusEvent verbose: event:03130001, msg:'Wait for post process',  submsg:'Exit Wait for post process Stage No2, Y-axis(Front Side), (Rear Lane),  ID:                '
    10:12:28.571 INFO INFO McEvent (ExitWaitPostProcess) Stage: 2 

我的正则表达式应该如何提取 McReplay 之后的内容,直到以时间戳开头的第一行。我在文件中出现了几次,我需要所有这些。

我想到了类似的东西

               new Regex(@"^(\d\d:\d\d:\d\d\.\d\d\d) INFO McReplay:(.*?)(\d\d:\d\d:\d\d\.\d\d\d)",
                           RegexOptions.Singleline | RegexOptions.Multiline);

似乎我对这部分有疑问(.*?)(\d\d:\d\d:\d\d\.\d\d\d)

我应该在这里解决什么?

4

1 回答 1

1

这将找到所有出现

     List<string> results = new List<string>();
     MatchCollection mc = Regex.Matches("yourstring", "McReplay:(.+?)[0-9]{2}:[0-9]{2}:[0-9]{2}", RegexOptions.Singleline);
     foreach (Match item in mc)
     {
        results.Add(item.Result("$1"));
     }
于 2013-01-06T13:10:09.123 回答