using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections.Generic;
private static readonly Regex regex = new Regex(@"^\d+(?=\.)", RegexOptions.Compiled);
public static void Main()
var comparer = new GenericCompare<string>(s => regex.Match(s).Value);
var distinctWithNumbers = list.Where(s => regex.IsMatch(s)).GroupBy(s => regex.Match(s).Value).Select(g => g.First());
distinctWithNumbers.ToList().ForEach(Console.WriteLine);
public class GenericCompare<T> : IEqualityComparer<T> where T : class
private Func<T, object> _expr { get; set; }
public GenericCompare(Func<T, object> expr)
public bool Equals(T x, T y)
var first = _expr.Invoke(x);
var sec = _expr.Invoke(y);
if (first != null && first.Equals(sec))
public int GetHashCode(T obj)
return _expr.Invoke(obj).GetHashCode();