[2] Fri 04Jun10 13:57:00 - (000035) USER t
[2] Fri 04Jun10 13:57:00 - (000035) PASS xxxxx
[2] Fri 04Jun10 13:57:00 - (000035) SYST
[2] Fri 04Jun10 13:57:00 - (000035) FEAT
[2] Fri 04Jun10 13:57:00 - (000035) CLNT FlashFXP 3.4.1.1149
[2] Fri 04Jun10 13:57:07 - (000035) RETR vssver.scc
[3] Fri 04Jun10 13:57:07 - (000035) Sending file d:\code\kenel\vssver.scc
[3] Fri 04Jun10 13:57:07 - (000035) Sent file d:\code\kenel\vssver.scc successfully (6.77 kB/sec - 208 Bytes)
[2] Fri 04Jun10 13:57:10 - (000035) RETR whatsnew.xml
[3] Fri 04Jun10 13:57:10 - (000035) Sending file d:\code\kenel\whatsnew.xml
[3] Fri 04Jun10 13:57:10 - (000035) Sent file d:\code\kenel\whatsnew.xml successfully (38.4 kB/sec - 944 Bytes)
[2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
[3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
[3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully (4.81 kB/sec - 128 Bytes)
[2] Fri 04Jun10 13:57:00 - (000035) USER t1
[2] Fri 04Jun10 13:57:00 - (000035) PASS xxxxx
[2] Fri 04Jun10 13:57:00 - (000035) SYST
[2] Fri 04Jun10 13:57:00 - (000035) FEAT
[2] Fri 04Jun10 13:57:00 - (000035) CLNT FlashFXP 3.4.1.1149
[2] Fri 04Jun10 13:57:07 - (000035) RETR vssver.scc
[3] Fri 04Jun10 13:57:07 - (000035) Sending file d:\code\kenel\vssver.scc
[3] Fri 04Jun10 13:57:07 - (000035) Sent file d:\code\kenel\vssver.scc successfully (6.77 kB/sec - 208 Bytes)
[2] Fri 04Jun10 13:57:10 - (000035) RETR whatsnew.xml
[3] Fri 04Jun10 13:57:10 - (000035) Sending file d:\code\kenel\whatsnew.xml
[3] Fri 04Jun10 13:57:10 - (000035) Sent file d:\code\kenel\whatsnew.xml successfully (38.4 kB/sec - 944 Bytes)
[2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
[3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
[3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully (4.81 kB/sec - 128 Bytes)

解决方案 »

  1.   

    USER t 为起始识别标识,需要截取Sent file d:\code\kenel\whatsnew.xml successfully 内的文件全路径。
      

  2.   

    目前我的正则是这样的:USER\st\b.+Sent\sfile\s(.+)\ssuccessfully
    不会写后面的截止条件
      

  3.   

    Sent file d:\code\kenel\whatsnew.xml successfully 的文件路径?
    还是要你标出的红色部分的文本?有很多sent 文件的,有什么规律? Regex.Match("Sent file d:\code\kenel\whatsnew.xml successfully",@"(?i)[a-z]:(\\[^\\/: ?'""*<>]+)+").Value;能获得文件路径。但是你要其他的话,你要总结一下规律。
      

  4.   

    测试:
            private static void TestRegex19()
            {
                string yourStr = @"[2] Fri 04Jun10 13:57:00 - (000035) USER t
    [2] Fri 04Jun10 13:57:00 - (000035) PASS xxxxx
    [2] Fri 04Jun10 13:57:00 - (000035) SYST
    [2] Fri 04Jun10 13:57:00 - (000035) FEAT
    [2] Fri 04Jun10 13:57:00 - (000035) CLNT FlashFXP 3.4.1.1149
    [2] Fri 04Jun10 13:57:07 - (000035) RETR vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sending file d:\code\kenel\vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sent file d:\code\kenel\vssver.scc successfully (6.77 kB/sec - 208 Bytes)
    [2] Fri 04Jun10 13:57:10 - (000035) RETR whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sending file d:\code\kenel\whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sent file d:\code\kenel\whatsnew.xml successfully (38.4 kB/sec - 944 Bytes)
    [2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully (4.81 kB/sec - 128 Bytes)
    [2] Fri 04Jun10 13:57:00 - (000035) USER t1
    [2] Fri 04Jun10 13:57:00 - (000035) PASS xxxxx
    [2] Fri 04Jun10 13:57:00 - (000035) SYST
    [2] Fri 04Jun10 13:57:00 - (000035) FEAT
    [2] Fri 04Jun10 13:57:00 - (000035) CLNT FlashFXP 3.4.1.1149
    [2] Fri 04Jun10 13:57:07 - (000035) RETR vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sending file d:\code\kenel\vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sent file d:\code\kenel\vssver.scc successfully (6.77 kB/sec - 208 Bytes)
    [2] Fri 04Jun10 13:57:10 - (000035) RETR whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sending file d:\code\kenel\whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sent file d:\code\kenel\whatsnew.xml successfully (38.4 kB/sec - 944 Bytes)
    [2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully (4.81 kB/sec - 128 Bytes)
    ";
                MatchCollection mc = Regex.Matches(yourStr, @"(?is)(?<=USER t\b.+?)[a-z]:(\\[^\\/: ?'""*<>\r\n]+)+(?=.+?USER|$)");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }
            }
    结果:d:\code\kenel\vssver.scc
    d:\code\kenel\vssver.scc
    d:\code\kenel\whatsnew.xml
    d:\code\kenel\whatsnew.xml
    d:\code\kenel\appconfig.properties
    d:\code\kenel\appconfig.properties
      

  5.   

    就是先截取USER t与非USER t之间的内容
    然后在这之间提取send file ... successfully之间的全路径.
     
      

  6.   


            private static void TestRegex19()
            {
                string yourStr = @"[2] Fri 04Jun10 13:57:00 - (000035) USER t
    [2] Fri 04Jun10 13:57:00 - (000035) PASS xxxxx
    [2] Fri 04Jun10 13:57:00 - (000035) SYST
    [2] Fri 04Jun10 13:57:00 - (000035) FEAT
    [2] Fri 04Jun10 13:57:00 - (000035) CLNT FlashFXP 3.4.1.1149
    [2] Fri 04Jun10 13:57:07 - (000035) RETR vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sending file d:\code\kenel\vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sent file d:\code\kenel\vssver.scc successfully (6.77 kB/sec - 208 Bytes)
    [2] Fri 04Jun10 13:57:10 - (000035) RETR whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sending file d:\code\kenel\whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sent file d:\code\kenel\whatsnew.xml successfully (38.4 kB/sec - 944 Bytes)
    [2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully (4.81 kB/sec - 128 Bytes)
    [2] Fri 04Jun10 13:57:00 - (000035) USER t1
    [2] Fri 04Jun10 13:57:00 - (000035) PASS xxxxx
    [2] Fri 04Jun10 13:57:00 - (000035) SYST
    [2] Fri 04Jun10 13:57:00 - (000035) FEAT
    [2] Fri 04Jun10 13:57:00 - (000035) CLNT FlashFXP 3.4.1.1149
    [2] Fri 04Jun10 13:57:07 - (000035) RETR vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sending file d:\code\kenel\vssver.scc
    [3] Fri 04Jun10 13:57:07 - (000035) Sent file d:\code\kenel\vssver.scc successfully (6.77 kB/sec - 208 Bytes)
    [2] Fri 04Jun10 13:57:10 - (000035) RETR whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sending file d:\code\kenel\whatsnew.xml
    [3] Fri 04Jun10 13:57:10 - (000035) Sent file d:\code\kenel\whatsnew.xml successfully (38.4 kB/sec - 944 Bytes)
    [2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully (4.81 kB/sec - 128 Bytes)
    ";
                MatchCollection mc = Regex.Matches(yourStr, @"(?is)(?<=USER t\b.+?)[a-z]:(\\[^\\/: ?'""*<>\r\n]+)+(?= successfully)(?=.+?USER|$)");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }
            }
    运行结果:
    d:\code\kenel\vssver.scc
    d:\code\kenel\whatsnew.xml
    d:\code\kenel\appconfig.properties
      

  7.   

    谢谢wuyazhe,稍微有一点没有满足。
    eg:
    USER t
    [3] Fri 04Jun10 13:57:10 - (000035) Sent file d:\code\kenel\whatsnew.xml successfully (38.4 kB/sec - 944 Bytes)
    [2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully (4.81 kB/sec - 128 Bytes)
    asdasasaaookj
    USER t1
    [2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t
    [2] Fri 04Jun10 13:57:16 - (000035) RETR AppConfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sending file d:\code\kenel\appconfig.properties
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
      

  8.   

    楼上的(?is)是.net特有的语法吧
      

  9.   

    是的。你如果不是.net,就用属性,js中就是
    /regex/igs
      

  10.   

    好像还是不行:
    USER t
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t3
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t2
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully红色为需要捕获的内容
      

  11.   

            private static void TestRegex19()
            {
                string yourStr = @"USER t
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t3
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t2
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully";
                MatchCollection mc = Regex.Matches(yourStr, @"(?is)(?<=USER t\b.+?)[a-z]:(\\[^\\/: ?'""*<>\r\n]+)+(?= successfully)(?=.+?(?:USER|$))");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }
            }
      

  12.   

    private static void TestRegex19()
    {
    string yourStr = @"USER t
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t3
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t2
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    USER t
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully
    [3] Fri 04Jun10 13:57:16 - (000035) Sent file d:\code\kenel\appconfig.properties successfully";
    MatchCollection mc = Regex.Matches(yourStr, @"(?is)(?<=USER t\b.+?)[a-z]:(\\[^\\/: ?'""*<>\r\n]+)+(?= successfully)(?=.+?(?:USER|$))");
    foreach (Match m in mc)
    {
    Console.WriteLine(m.Value);
    }
    }