I would like to split a string into fixed-length (N, for example) pieces. Of course, last piece could be shorter, if original string\'s length is not multiple of N<
You can try this:
var a = 'aaaabbbbccccee'; var b = a.match(/(.{1,4})/g);