Support wildcard in history form filename filter

This commit is contained in:
Jaex 2019-04-09 11:46:32 +03:00
parent d0f9b46075
commit 457e13b7bb

View file

@ -30,6 +30,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace ShareX.HistoryLib
@ -149,7 +150,9 @@ private HistoryItem[] ApplyFilters(HistoryItem[] historyItems)
if (!string.IsNullOrEmpty(filenameFilter))
{
result = result.Where(x => x.Filename != null && x.Filename.Contains(filenameFilter, StringComparison.InvariantCultureIgnoreCase));
string pattern = Regex.Escape(filenameFilter).Replace("\\?", ".").Replace("\\*", ".*");
Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
result = result.Where(x => x.Filename != null && regex.IsMatch(x.Filename));
}
string urlFilter = txtURLFilter.Text;