Split string once in javascript?
This isn't a pretty approach, but works with decent efficiency:
var string = "1|Ceci n'est pas une pipe: | Oui";
var components = string.split('|');
alert([components.shift(), components.join('|')]);
Here's a quick demo of it
You'd want to use String.indexOf('|')
to get the index of the first occurrence of '|'.
var i = s.indexOf('|');
var splits = [s.slice(0,i), s.slice(i+1)];