This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://stackoverflow.com/questions/3102250/linq-search-using-wildcards-character-like | |
public static class EnumerableExtensions | |
{ | |
public static IEnumerable<T> MatchesWildcard<T>(this IEnumerable<T> sequence, Func<T,string> expression, string pattern) | |
{ | |
var regEx = WildcardToRegex(pattern); | |
return sequence.Where(item => Regex.IsMatch(expression(item), regEx)); | |
} | |
public static string WildcardToRegex(string pattern) |
NewerOlder