fork 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 Regex rx = new Regex(@"^(TC_)_?(\d+).*", RegexOptions.Compiled);
  10. public class FilePathComparer : IEqualityComparer<string>
  11. {
  12. public bool Equals(string x, string y)
  13. {
  14. return rx.Replace(x, "$1$2") == rx.Replace(y, "$1$2");
  15. }
  16. public int GetHashCode(string s)
  17. {
  18. return rx.Replace(s,"$1$2").GetHashCode();
  19. }
  20. }
  21. public static void Main()
  22. {
  23. var FileNames_List_Jetzt_Dateien = new List<string> { "TC__6493_8exp","TC__6494_8exp","TC__6495_8exp"};
  24. var TEST_FÄLLE = new List<string> { "TC_6493","TC_6494","TC_6495"};
  25. var intersected = FileNames_List_Jetzt_Dateien.Intersect(TEST_FÄLLE, new FilePathComparer());
  26. foreach (var s in intersected)
  27. Console.WriteLine(s);
  28. }
  29. }
Success #stdin #stdout 0.08s 28500KB
stdin
Standard input is empty
stdout
TC__6493_8exp
TC__6494_8exp
TC__6495_8exp