Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1.  private bool IsColumnInFilter(List<string> filterColumns, string column)
  2.         {
  3.             if (column == null || string.IsNullOrEmpty(column))
  4.             {
  5.                 return false;
  6.             }
  7.  
  8.             foreach (string filterColumn in filterColumns)
  9.             {
  10.                 if (column.Contains(filterColumn, StringComparison.OrdinalIgnoreCase))
  11.                 {
  12.                     Regex regex = new Regex($@"(\A|\W){filterColumn}(\W|\Z)", RegexOptions.IgnoreCase);
  13.                     MatchCollection matches = regex.Matches(column);
  14.  
  15.                     if (matches.Count > 0)
  16.                     {
  17.                         return true;
  18.                     }
  19.                 }
  20.             }
  21.  
  22.             return false;
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement