From 5eb517780c1c3beb3d71beaa29f4691b897d7bda Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 8 Feb 2017 20:38:29 -0800 Subject: [PATCH] [Filter] Add unused flag for regex compatibile level --- SabreTools.Helper/Dats/Filter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SabreTools.Helper/Dats/Filter.cs b/SabreTools.Helper/Dats/Filter.cs index 28014fcd..571d44c8 100644 --- a/SabreTools.Helper/Dats/Filter.cs +++ b/SabreTools.Helper/Dats/Filter.cs @@ -470,7 +470,7 @@ namespace SabreTools.Helper.Dats /// Value to search the list for /// True if the value could be found, false otherwise /// TODO: Add proper regex matching to all strings - private bool FindValueInList(List haystack, string needle) + private bool FindValueInList(List 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);