fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var s = "[Wed Dec 17 14:40:28 2014] [error] [client 143.117.101.166] File does not exist:";
  9. var r = new Regex(@"(\[[^\]]*\]\s*\[[^\]]*\]\s*\[[^\]]*\])(.*)$");
  10. var m = r.Match(s);
  11. if (m.Success) {
  12. Console.WriteLine("Prefix: {0}", m.Groups[1]);
  13. Console.WriteLine("Error: {0}", m.Groups[2]);
  14. }
  15. }
  16. }
Success #stdin #stdout 0.03s 133824KB
stdin
Standard input is empty
stdout
Prefix: [Wed Dec 17 14:40:28 2014] [error] [client 143.117.101.166]
Error:  File does not exist: