fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string pattern = @"^(?!.*\bTest12\b).*?(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2,}(?:,\d{3}\b)?).*\bCorrect\b.*$";
  9. string input = @"Line 1: 2019-01-22 15:36:141,023: [Test][123] INFORMATION - Testing: Correct Test12 ping
  10.  
  11. Line 2: 2019-01-22 15:36:141,023: [Test][124323] INFORMATION - Testing: Wrong Test12 ping
  12.  
  13. Line 3: 2019-01-22 15:36:141,023: [Test][12554363] INFORMATION - Testing: Correct Test ping
  14.  
  15. Line 4: 2019-01-22 15:36:141,023: [Test][6761213] INFORMATION - Testing: Wrong Test12 ping
  16.  
  17. Line 5: 2019-01-22 15:36:141,023: [Test][46543123] INFORMATION - Testing: Invalid Test ping
  18.  
  19. Line 6: 2019-01-22 15:36:141,023: [Test][887] INFORMATION - Testing: Correct Test ping";
  20. RegexOptions options = RegexOptions.Multiline;
  21.  
  22. foreach (Match m in Regex.Matches(input, pattern, options))
  23. {
  24. Console.WriteLine(m.Groups[1]);
  25. }
  26. }
  27. }
Success #stdin #stdout 0.04s 134592KB
stdin
Standard input is empty
stdout
2019-01-22 15:36:141,023
2019-01-22 15:36:141,023