fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string lines = "2019-05-07 11:50:28, INFO Ayush Singhania, Level 1, EID: 1001, UID: ayush.power, Message: Create a Job";
  9. Regex pattern = new Regex(@"(?<Date>.*?\s)(?<Time>.*?), INFO(?<Name>.*?),(?<Level>.*?), EID: (?<EID>.*?), UID: (?<UID>.*?), Message: (?<MSG>.*)");
  10.  
  11. MatchCollection myMatchCollection = pattern.Matches(lines);
  12. foreach (Match myMatch in myMatchCollection)
  13. {
  14. var Date = myMatch.Groups["Date"].Value;
  15. var Time = myMatch.Groups["Time"].Value;
  16. var Name = myMatch.Groups["Name"].Value;
  17. var Level = myMatch.Groups["Level"].Value;
  18. var EID = myMatch.Groups["EID"].Value;
  19. var UID = myMatch.Groups["UID"].Value;
  20. var Message = myMatch.Groups["MSG"].Value;
  21.  
  22. Console.Out.WriteLine(Date);
  23. Console.Out.WriteLine(Time);
  24. Console.Out.WriteLine(Name);
  25. Console.Out.WriteLine(Level);
  26. Console.Out.WriteLine(EID);
  27. Console.Out.WriteLine(UID);
  28. Console.Out.WriteLine(Message);
  29. }
  30. }
  31. }
Success #stdin #stdout 0.03s 134592KB
stdin
Standard input is empty
stdout
2019-05-07 
11:50:28
 Ayush Singhania
 Level 1
1001
ayush.power
Create a Job