From 89448838a1295041293bbd5dd69501ad934bdf03 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 21 Oct 2023 12:32:21 +0200 Subject: [PATCH] Add more regex options --- DataManagerExtensions.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/DataManagerExtensions.cs b/DataManagerExtensions.cs index b4e7210..a308258 100644 --- a/DataManagerExtensions.cs +++ b/DataManagerExtensions.cs @@ -40,7 +40,7 @@ public static class DataManagerExtensions if (payload is TextPayload) return Regex.Escape(payload.RawString); else - return ".*"; + return "(.*)"; })); pluginLog?.Verbose($"{typeof(T).Name}.{key} => /{regex}/"); return new Regex(regex); @@ -77,9 +77,27 @@ public static class DataManagerExtensions if (payload is TextPayload) return Regex.Escape(payload.RawString); else - return ".*"; + return "(.*)"; })); pluginLog?.Verbose($"{typeof(T).Name}.{rowId} => /{regex}/"); return new Regex(regex); } + + public static Regex? GetRegex(this T excelRow, Func mapper, IPluginLog? pluginLog) + where T : ExcelRow + { + SeString? text = mapper(excelRow); + if (text == null) + return null; + + string regex = string.Join("", text.Payloads.Select(payload => + { + if (payload is TextPayload) + return Regex.Escape(payload.RawString); + else + return "(.*)"; + })); + pluginLog?.Verbose($"{typeof(T).Name}.regex => /{regex}/"); + return new Regex(regex); + } }