I have the following code that converts a string that looks like aaa-bbb|ccc-ddd|eee-fff
to two strings that look like aaa|ccc|eee
and bbb|ddd|fff
.
var id = "HEL-CAS|MAD-STO|XXX-YYY"
var splittedId = id.split('|');
var from = "", to = "";
$(splittedId).each(function(a,b) {
from = from + b.split("-")[0]+"|";
to = to + b.split("-")[1] + "|";
});
from = from.substring(0,from.length-1);
to = to.substring(0,to.length-1);