fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. string InputText = "12/03/2015 *** [RandomText] // 1.04.1112V";
  12. string regex = @"([0-9/]*) \*\*\* \[([A-Za-z]*)\] \/\/ (.*)";
  13. string Name = "GoogleChrome";
  14. string OutputPattern1 = "{1} - {Name} version {3}";
  15. string OutputPattern2 = "{Name}_{3}";
  16. string rx = @"{(?:(\d+)|Name)}";
  17. var match = Regex.Match(InputText, regex);
  18. if (match.Success) {
  19. Console.WriteLine(
  20. Regex.Replace(OutputPattern1, rx, x=>
  21. x.Groups[1].Success? match.Groups[int.Parse(x.Groups[1].Value)].Value : Name)
  22. );
  23. Console.WriteLine(
  24. Regex.Replace(OutputPattern2, rx, x=>
  25. x.Groups[1].Success? match.Groups[int.Parse(x.Groups[1].Value)].Value : Name)
  26. );
  27. }
  28. }
  29. }
  30.  
Success #stdin #stdout 0.08s 29564KB
stdin
Standard input is empty
stdout
12/03/2015 - GoogleChrome version 1.04.1112V
GoogleChrome_1.04.1112V