fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var str = "JAN 01 00:00:01 <Admin> Action, May have spaces etc.";
  9. var re = new Regex("^" +
  10. @"(?<month>(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))" +
  11. " " +
  12. @"(?<day>\d+)" +
  13. " " +
  14. @"(?<hour>\d+)" +
  15. ":" +
  16. @"(?<the_rest>.*)" +
  17. "$");
  18. var match = re.Match(str);
  19.  
  20. if (match.Success) {
  21. Console.WriteLine("Day = " + match.Groups["day"].Value);
  22. }
  23.  
  24. }
  25. }
Success #stdin #stdout 0.08s 37336KB
stdin
Standard input is empty
stdout
Day = 01