Skip to content

Instantly share code, notes, and snippets.

@gkatsev
Created October 11, 2012 04:17
Show Gist options
  • Save gkatsev/3870132 to your computer and use it in GitHub Desktop.
Save gkatsev/3870132 to your computer and use it in GitHub Desktop.
String.prototype.splitSome = function(del, n){
var a = this.split(del)
, b = a.slice(n).join(del)
a.length = n
a[a.length] = b
return a
};
"one,two,three,four,five".splitSome(',', 3)
// -> ['one', 'two', 'three', 'four,five']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment