fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var groups = new Dictionary<string, string>
  11. {
  12. { "month", @"(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)" },
  13. { "day", @"\d+" },
  14. { "hour", @"\d+" },
  15. { "the_rest", @".*" },
  16. };
  17.  
  18. var format = "{month} {day} {hour}:{the_rest}";
  19. var result = Regex.Replace(format, @"\{(\w+)\}", m => groups[m.Groups[1].Value]);
  20.  
  21. Console.WriteLine(result);
  22. }
  23. }
Success #stdin #stdout 0.08s 38320KB
stdin
Standard input is empty
stdout
(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) \d+ \d+:.*