fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string[] strings = {"fx_2019.csv", "fx_201902.csv"};
  9. foreach (string s in strings)
  10. {
  11. string myYear = Regex.Replace(s, @".*_(20[0-9]{2})[0-9]*\.\w+$", "$1");
  12. Console.WriteLine(myYear);
  13. }
  14. }
  15. }
Success #stdin #stdout 0.08s 21120KB
stdin
Standard input is empty
stdout
2019
2019