var str = 'abcdefghijkl'; console.log(str.match(/.{1,3}/g));
console.log("abcd".match(/.{1,2}/g)); // ["ab", "cd"]