membagi string setiap n karakter javascript
console.log("abcd".match(/.{1,2}/g)); // ["ab", "cd"]
Lazy Lion
console.log("abcd".match(/.{1,2}/g)); // ["ab", "cd"]
var str = "This is an amazing sentence.";
var words = str.split(" ");
console.log(words);
//["This", "is", "an", "amazing", "sentence."]
var arr= [];
"hell@o wor&ld".split(/(\W)/).forEach(function(elem) {
if (!/^\s*$/.test(elem)) {
arr.push(elem);
}
});