mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-31 11:31:16 -06:00
made renamer replace empty [] and ()s made renamer use a safe file name from nodeparameters fixed issue with pattern match returning 0 instead of 2 for no match added dummy data to variables so UI can preview variable replacements
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
namespace FileFlows.BasicNodes.Functions
|
|
{
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Text.RegularExpressions;
|
|
using FileFlows.Plugin;
|
|
using FileFlows.Plugin.Attributes;
|
|
public class PatternMatch : Node
|
|
{
|
|
public override int Inputs => 1;
|
|
public override int Outputs => 2;
|
|
public override FlowElementType Type => FlowElementType.Logic;
|
|
public override string Icon => "fas fa-equals";
|
|
|
|
[DefaultValue("")]
|
|
[Text(1)]
|
|
[Required]
|
|
public string Pattern { get; set; }
|
|
|
|
public override int Execute(NodeParameters args)
|
|
{
|
|
if (string.IsNullOrEmpty(Pattern))
|
|
return 1; // no pattern, matches everything
|
|
|
|
try
|
|
{
|
|
var rgx = new Regex(Pattern);
|
|
if (rgx.IsMatch(args.WorkingFile) || rgx.IsMatch(args.FileName))
|
|
return 1;
|
|
return 2;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
args.Logger?.ELog("Pattern error: " + ex.Message);
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
} |