Skip to content

Instantly share code, notes, and snippets.

@UlisesGascon
Forked from hendriklammers/splitString.js
Last active August 29, 2015 14:24
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 UlisesGascon/ddf622899dcfed478c34 to your computer and use it in GitHub Desktop.
Save UlisesGascon/ddf622899dcfed478c34 to your computer and use it in GitHub Desktop.
/**
* Split a string into chunks of the given size
* @param {String} string is the String to split
* @param {Number} size is the size you of the cuts
* @return {Array} an Array with the strings
*/
function splitString (string, size) {
var re = new RegExp('.{1,' + size + '}', 'g');
return string.match(re);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment