javascript split every second character code example
Example 1: split every n character js
var str = 'abcdefghijkl';
console.log(str.match(/.{1,3}/g));
Example 2: js split string every n characters
foo.match(new RegExp('.{1,' + n + '}', 'g'));
var str = 'abcdefghijkl';
console.log(str.match(/.{1,3}/g));
foo.match(new RegExp('.{1,' + n + '}', 'g'));