There are many ways of doing this. I have used something similar as I demonstrate in below script (using associative array)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Probe.jmp");
aa_groups = ["DELL" => {}, "DELW" => {}, "RCON" => {}];
col_names = dt << Get Column Names("String");
For Each({col_name}, col_names,
For Each({{key, value}}, aa_groups,
If(Starts With(col_name, key ||"_"), // "_" is used as additional separator
Insert Into(aa_groups[key], col_name);
Break();
)
);
);
For Each({{groupname, groupcols}}, aa_groups,
dt << Group Columns(groupname, groupcols);
);
If you need to go more dynamic you can also do that
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Probe.jmp");
aa_groups = Associative Array();
col_names = dt << Get Column Names("String");
For Each({col_name}, col_names,
nameparts = Words(col_name, "_"); // depending ion your columns, this might need to change
If(N Items(nameparts) > 1,
If(!Contains(aa_groups, nameparts[1]),
aa_groups[nameparts[1]] = {}; // add new key
);
Insert Into(aa_groups[nameparts[1]], col_name);
);
);
For Each({{groupname, groupcols}}, aa_groups,
dt << Group Columns(groupname, groupcols);
);
Idea is the same in both. Create associative array where they keys are column group names and the values are list of columns which belong to that group.
-Jarmo