Add more Regex functions
This commit is contained in:
parent
9db9f95b8c
commit
43c3dba112
@ -79,15 +79,9 @@ public static class DataManagerExtensions
|
|||||||
if (text == null)
|
if (text == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string regex = string.Join("", text.Payloads.Select(payload =>
|
Regex regex = text.ToRegex();
|
||||||
{
|
|
||||||
if (payload is TextPayload)
|
|
||||||
return Regex.Escape(payload.RawString);
|
|
||||||
else
|
|
||||||
return "(.*)";
|
|
||||||
}));
|
|
||||||
pluginLog?.Verbose($"{typeof(T).Name}.{rowId} => /{regex}/");
|
pluginLog?.Verbose($"{typeof(T).Name}.{rowId} => /{regex}/");
|
||||||
return new Regex(regex);
|
return regex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Regex? GetRegex<T>(this T excelRow, Func<T, SeString?> mapper, IPluginLog? pluginLog)
|
public static Regex? GetRegex<T>(this T excelRow, Func<T, SeString?> mapper, IPluginLog? pluginLog)
|
||||||
@ -99,14 +93,20 @@ public static class DataManagerExtensions
|
|||||||
if (text == null)
|
if (text == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string regex = string.Join("", text.Payloads.Select(payload =>
|
Regex regex = text.ToRegex();
|
||||||
|
pluginLog?.Verbose($"{typeof(T).Name}.regex => /{regex}/");
|
||||||
|
return regex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Regex ToRegex(this SeString? text)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(text);
|
||||||
|
return new Regex(string.Join("", text.Payloads.Select(payload =>
|
||||||
{
|
{
|
||||||
if (payload is TextPayload)
|
if (payload is TextPayload)
|
||||||
return Regex.Escape(payload.RawString);
|
return Regex.Escape(payload.RawString);
|
||||||
else
|
else
|
||||||
return "(.*)";
|
return "(.*)";
|
||||||
}));
|
})));
|
||||||
pluginLog?.Verbose($"{typeof(T).Name}.regex => /{regex}/");
|
|
||||||
return new Regex(regex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user