using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static Regex rx = new Regex(@"^(TC_)_?(\d+).*", RegexOptions.Compiled); public class FilePathComparer : IEqualityComparer { public bool Equals(string x, string y) { return rx.Replace(x, "$1$2") == rx.Replace(y, "$1$2"); } public int GetHashCode(string s) { return rx.Replace(s,"$1$2").GetHashCode(); } } public static void Main() { var FileNames_List_Jetzt_Dateien = new List { "TC__6493_8exp","TC__6494_8exp","TC__6495_8exp"}; var TEST_FÄLLE = new List { "TC_6493","TC_6494","TC_6495"}; var intersected = FileNames_List_Jetzt_Dateien.Intersect(TEST_FÄLLE, new FilePathComparer()); foreach (var s in intersected) Console.WriteLine(s); } }