For me it seems to be working fine. You can change the example table to semiconductor capability and check for some numbers at the end
Names default to here(1);
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
collist = dt << get column names(string);
hcols = Filter Each({colname}, colList,
Ends With(colname, "1");
);
aa = Associative Array();
For Each({hcolname}, hcols,
lcolname = Left(hcolname, Length(hcolname) - 1) || "2";
If(dt << Has Column(lcolname),
aa[hcolname] = lcolname
);
);
Show(aa);
aa = ["ESM1" => "ESM2", "FST1" => "FST2", "INM1" => "INM2", "IVP1" => "IVP2", "NPN1" => "NPN2", "PBA1" => "PBA2", "PLG1" => "PLG2", "PLY1" => "PLY2", "PNP1" => "PNP2", "RES1" => "RES2", "RSP1" => "RSP2", "SIT1" => "SIT2", "VDP1" => "VDP2", "VPM1" => "VPM2"];
But you could also go a bit different route with a bit more configuration options
Names Default To Here(1);
endchar1 = "1";
endchar2 = "2";
rgx_endchar1 = Eval Insert("(.+?)^endchar1^$");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
collist = dt << get column names(string);
aa = Associative Array();
For Each({colname}, collist,
col_ptrn = Regex(colname, rgx_endchar1, "\1");
If(!IsMissing(col_ptrn), // ends with H
If(Contains(collist, col_ptrn || endchar2),
aa[col_ptrn || endchar1] = col_ptrn || endchar2;
);
);
);
show(aa);
Both of these do return same results for me
-Jarmo