mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Filter] Add unused flag for regex compatibile level
This commit is contained in:
@@ -470,7 +470,7 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="needle">Value to search the list for</param>
|
||||
/// <returns>True if the value could be found, false otherwise</returns>
|
||||
/// <remarks>TODO: Add proper regex matching to all strings</remarks>
|
||||
private bool FindValueInList(List<string> haystack, string needle)
|
||||
private bool FindValueInList(List<string> haystack, string needle, bool regex = false)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (string straw in haystack)
|
||||
@@ -478,7 +478,7 @@ namespace SabreTools.Helper.Dats
|
||||
if (!String.IsNullOrEmpty(straw))
|
||||
{
|
||||
// Pre-process the straw to make it regex-compatibile
|
||||
string regexStraw = "^" + (straw.StartsWith("*") ? ".*" : "") + Regex.Escape(straw.Trim('*')) + (straw.EndsWith("*") ? ".*" : "") + "$";
|
||||
string regexStraw = (!regex ? "^" + (straw.StartsWith("*") ? ".*" : "") + Regex.Escape(straw.Trim('*')) + (straw.EndsWith("*") ? ".*" : "") + "$" : straw);
|
||||
|
||||
// Check if a match is found with the regex
|
||||
found |= Regex.IsMatch(needle, straw, RegexOptions.IgnoreCase);
|
||||
|
||||
Reference in New Issue
Block a user