Here you can find the source of split(separator, nbr)
String.prototype.split = function(separator, nbr) { var results = []; var pt = ""; var ct = 0;//w w w.j a v a 2 s . c o m for (var i = 0, len = this.length; i < len; i++) { if (this[i] == separator) { results.push(pt); pt = ""; ct++; if (nbr && ct >= nbr) { separator = ""; } } else { pt += this[i]; } } results.push(pt); return results; };
String.prototype.split140chars = function(){ const results = [ "" ]; for(let line of this.split(/[\r\n]/)){ if(results[0].length + line.length + 1 > 140){ results.unshift(""); if(results[0].length > 0) results[0] += "\n"; results[0] += line; return results.reverse(); };
String.prototype.split2 = function(a, b) { var lines = this.split(a); for (var i = 0; i < lines.length; i++) lines.splice.apply(lines, [i, 1].concat(lines[i].split(b))); return lines; }; String.prototype.lines = function() { return this.split2('\r', '\n'); }; ...
String.prototype.split2 = function(s) { var rg = this.split(s); if ((rg.length == 1) && (rg[0] === '')) return []; return rg; };
String.prototype.splitANArguments = function(){ var r = []; var t = ''; var isQuote = false; for(var i = 0; i < this.length; i++){ if(!isQuote && this.charAt(i) == ' '){ r.push(t); t = ''; else{ if(this.charAt(i) == '"'){ t += this.charAt(i); isQuote = !isQuote; else{ t += this.charAt(i); r.push(t); return r;