The instring equivalent in JSL is contains. The menu option Help > Scripting Index is very helpful, btw.
This code groups each set of XXs and YYs into separate groups.
// Create a table to test things out on
dt = New Table( "Test", Add Rows( 3 ),
New Column( "XX1", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3] ) ),
New Column( "XX2", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3] ) ),
New Column( "YY1", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3] ) ),
New Column( "YY2", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3] ) )
);
// List of column names for the table
col_names = dt << get column names(string);
// String we're looking for
group_list = {"XX", "YY"};
// Loop over column groups
for (i = 1, i <= nitems(group_list), i++,
// Empty list to be populated with found columns
found_list = {};
one_group = group_list[i];
// Loop over all column names, looking for ones that start with "YY"
for (k = 1, k <= nitems(col_names), k++,
if (starts with(col_names[k], one_group),
insertinto(found_list, col_names[k]);
);
);
if (nitems(found_list) > 0,
dt << group columns(one_group, found_list);
);
);