Converting a string to two strings
You can use some ES6 functions and have something like:

var s = 'HEL-CAS|MAD-STO|XXX-YYY';
var s1 = [];
var s2 = []

for (var v of s.split('|').map(str =&gt; str.split('-'))) {
  s1.push(v[0])
  s2.push(v[1])
}

s1.join('|')
s2.join('|')