Javascript String splitFirst(separator)

Description

Javascript String splitFirst(separator)


String.prototype.splitFirst = function (separator) {
    var si = this.split(separator);
    var output = [];
    output.push(si[0]);//from w  w w .  j a  v  a  2s  . c o  m
    if (si.length>1) {
        si.shift();
        output.push(si.join(separator));
    }
    return output;
};



PreviousNext

Related