JSL error Not enough arguments in evaluation of 'Contains'I have a list of "file names" and I want to create a sub-list of only those that their names contain/end in "_2020". I am using a Regex to select for those files: "_\d{4}". However I am getting a "Not Enough Arguments" error.
If I test the ListIDs I get the expected list of file names, it is not empty. I will Appreciate any pointers on how to fix my script.
The log error is: not enough arguments in access or evaluation of 'Contains' , Contains/*###*/(Regex( Char( ListIDs[i] ), "_\d{4}" ))
Show (ListIDs);<BR />ListIDs = {"2020-06","practice", "file1_2020", "file2_2020"}<BR /><BR />SelectedIDs = {};
For (i = 1, i <= N Items (ListIDs), i++,
If (Contains(Regex(Char(ListIDs[i]), "_\d{4}")),
Insert Into (SelectedIDs, i);
);
);
N Items (SelectedIDs);
Print(SelectedIDs);ScriptingRe: JSL error Not enough arguments in evaluation of 'Contains'You need the second argument for Contains() function to designate the target string. Like this:
Show (ListIDs);ListIDs = {"2020-06","practice", "file1_2020", "file2_2020"}SelectedIDs = {};
For (i = 1, i <= N Items (ListIDs), i++,
If (Contains(Regex(Char(ListIDs[i]), "_\d{4}"), "2020"),
Insert Into (SelectedIDs, i);
);
);
N Items (SelectedIDs);
Print(SelectedIDs);Re: JSL error Not enough arguments in evaluation of 'Contains'Hi Mark,
Is the second argument the "Delimiter"? I would have thought that it would be "," not "2020". The goal of the Regex is to select only files that have "_2020" or in the future "_2021", "_2021" etc. Sorry if I am not explaining myself.
Re: JSL error Not enough arguments in evaluation of 'Contains'Hi,
I decided to modify the script and use the function Regex Match. This one got me closer to my goal. This one returns the position on the list of the expected filenames. How can I get the "Names" not their positions.
ListIDs = {"2019-11", "2020-06", "file1_2020", "file2_2020"};
SelectedIDs = {};
For (i = 1, i <= N Items (ListIDs), i++,
If ((Regex Match (Char(ListIDs[i]), "_\d{4}") !={}),
Insert Into (SelectedIDs, i);
);
);
N Items (SelectedIDs);
Print(SelectedIDs);