split a string based on a delimiter except when preceded by \
function(str, delim) {
      var res = []; 
      var segs = str.split(delim);
      var accum = '';
      for (let i = 0; i < segs.length; i++) {
        var seg = segs[i];
        if (seg.endsWith('\\')) {
          accum += seg.substring(0, seg.length - 1) + delim;
        }
        else {
          accum += seg;
          res.push(accum);
          accum = '';
        }
      }
      return res;
    }