I have a list of file names from which I want to select certain files. The first 4 digits are the year the underscore is acting like a deliminater, the "abc" is just an identifier for the type of file, the 3 digit number is the id, and "summary" or "result" refer to the kind of file.
First, I only want to look at the "result" files. I couldn't figure out how to remove all the "summary" files from my list.
{"2021_abc_027_result.csv", "2021_abc_027_summary.csv", "2021_abc_028_result.csv",
"2021_abc_028_summary.csv", "2021_abc_029_result.csv", "2021_abc_029_summary.csv",
"2021_abc_038_result.csv", "2021_abc_038_summary.csv", "2021_abc_040_result.csv",
"2021_abc_040_summary.csv", "2021_abc_041_result.csv", "2021_abc_041_summary.csv",
"2021_abc_042_result.csv", "2021_abc_042_summary.csv", "2021_abc_043_result.csv",
"2021_abc_043_summary.csv", "2021_abc_044_result.csv", "2021_abc_044_summary.csv",
"2021_abc_045_result.csv", "2021_abc_045_summary.csv", "2021_abc_046_result.csv",
"2021_abc_046_summary.csv", "2021_abc_047_result.csv", "2021_abc_047_summary.csv",
"2021_abc_048_result.csv", "2021_abc_048_summary.csv", "2021_abc_049_result.csv",
"2021_abc_049_summary.csv", "2021_abc_050_result.csv", "2021_abc_050_summary.csv",
"2021_abc_051_result.csv", "2021_abc_051_summary.csv", "2021_abc_052_result.csv",
"2021_abc_052_summary.csv", "2021_abc_053_result.csv", "2021_abc_053_summary.csv",
"2021_abc_054_result.csv", "2021_abc_054_summary.csv", "2021_abc_055_result.csv",
"2021_abc_055_summary.csv", "2021_abc_056_result.csv", "2021_abc_056_summary.csv",
"2021_abc_057_result.csv", "2021_abc_057_summary.csv", "2021_abc_058_result.csv",
"2021_abc_058_summary.csv", "2021_abc_059_result.csv", "2021_abc_059_summary.csv",
"2021_abc_060_result.csv", "2021_abc_060_summary.csv", "2021_abc_061_result.csv",
"2021_abc_061_summary.csv", "2021_abc_062_result.csv", "2021_abc_062_summary.csv",
"2021_abc_063_result.csv", "2021_abc_063_summary.csv", "2021_abc_064_result.csv",
"2021_abc_064_summary.csv", "2021_abc_065_result.csv", "2021_abc_065_summary.csv",
"2021_abc_067_result.csv"}
Second, I want to select the files based on the year and 3 digit code.
I have done something similar in the past to select files using regex where there was only one number in the string so I used
For( i = 1, i <= N Items( FileList ), i++,
FileList[i] = regex(FileList[i], "([0-9]+)", "\1")
);
but in this case I end up with a list of "2021", "2021",...
Ideally I would end up with a list looking like
{"2021_027 ", "2021_027 ", "2021_028 ",
"2021_028 ", "2021_029 ", "2021_029 ",
"2021_038 ", "2021_038 ", "2021_040 ",
"2021_040 ", "2021_041 ", "2021_041 ",
"2021_042 ", "2021_042 ", "2021_043 ",
"2021_043 ", "2021_044 ", "2021_044 ",
"2021_045 ", "2021_045 ", "2021_046 ",
"2021_046 ", "2021_047 ", "2021_047 ",
"2021_048 ", "2021_048 ", "2021_049 ",
"2021_049 ", "2021_050 ", "2021_050 ",
"2021_051 ", "2021_051 ", "2021_052 ",
"2021_052 ", "2021_053 ", "2021_053 ",
"2021_054 ", "2021_054 ", "2021_055 ",
"2021_055 ", "2021_056 ", "2021_056 ",
"2021_057 ", "2021_057 ", "2021_058 ",
"2021_058 ", "2021_059 ", "2021_059 ",
"2021_060 ", "2021_060 ", "2021_061 ",
"2021_061 ", "2021_062 ", "2021_062 ",
"2021_063 ", "2021_063 ", "2021_064 ",
"2021_064 ", "2021_065 ", "2021_065 ",
"2021_067 "}
and then I could select from that list the files I want to use.
Also any tips on learning how to regex better are welcome.
Thank you!