diviser une chaîne à chaque n caractères javascript
console.log("abcd".match(/.{1,2}/g)); // ["ab", "cd"]
Lazy Lion
console.log("abcd".match(/.{1,2}/g)); // ["ab", "cd"]
let chunks = [];
for (let i = 0, charsLength = str.length; i < charsLength; i += 3) {
chunks.push(str.substring(i, i + 3));
}
var str = 'abcdefghijkl';
console.log(str.match(/.{1,3}/g));
foo.match(new RegExp('.{1,' + n + '}', 'g'));
// split the text into array of chars using empty string
console.log("ABCDEFGHIJK".split(''));
// split the text into array of chars using empty string and limit to 3 chars
console.log("ABCDEFGHIJK".split('', 3));