fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string fileLogs = @"[08:52:18] [ERROR] Ceci doit aparaitre
  9. [08:52:18] [WARN] Bonjour ";
  10. var result = Regex.Matches(fileLogs, @"\[(.+)\] \[(.+)\] (.+)");
  11.  
  12. foreach (Match match in result)
  13. {
  14. string time = match.Groups[1].Value;
  15. string type = match.Groups[2].Value;
  16. string messsage = match.Groups[3].Value;
  17. Console.WriteLine("{0} | {1} | {2}", time, type, messsage);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.13s 24720KB
stdin
Standard input is empty
stdout
08:52:18 | ERROR | Ceci doit aparaitre 
08:52:18 | WARN | Bonjour