javascript String.split() ( , , split()).
An example of this behavior:
console.log('a,b,c'.split(',', 2))
> ['a', 'b']
but not
> ['a', 'b,c']
as you expected.
Try using this split function:
function extended_split(str, separator, max) {
var out = [],
index = 0,
next;
while (!max || out.length < max - 1 ) {
next = str.indexOf(separator, index);
if (next === -1) {
break;
}
out.push(str.substring(index, next));
index = next + separator.length;
}
out.push(str.substring(index));
return out;
};
source
share