Skip to content

Instantly share code, notes, and snippets.

@lonnen
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lonnen/9635489 to your computer and use it in GitHub Desktop.
Save lonnen/9635489 to your computer and use it in GitHub Desktop.
a quick, simple but not very efficient answer to: https://twitter.com/peterbe/status/446139741902086145
function pySplit(str, sep, num) {
var pieces = str.split(sep)
if (arguments.length < 3) {
return pieces;
}
if (pieces.length < num) {
return pieces;
}
return pieces.slice(0, num).concat(pieces.slice(num).join(sep));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment