Something like this.
dt = Open( "$sample_data/big class.jmp" );
allCols = dt << getcolumnnames;
Show( allCols ); // these are names, not strings
acols = {}; // columns with "a" in their name
icols = {}; // columns with "i" in their name
n = N Items( allCols );
For( k = 1, k <= n, k++,
cname = allCols << getname; // these are strings, good for regex
Show( cname );
If( !Is Missing( Regex( cname, "a" ) ),
Insert Into( acols, allCols ) // keep the names
);
If( !Is Missing( Regex( cname, "i" ) ),
Insert Into( icols, allCols ) // keep the names
);
);
Show( acols, icols ); // {:name, :age} and {:height, :weight}
dt << Stack(
columns( icols ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
Craige