With simple logic
'4111111111111111'.match(/.{1,4}/g)
Other way
var str="4111111111111111";
var parts = [];
for (var i = 0; i < str.length; i += 4) {
parts.push(str.substring(i, i + 4));
}
console.log(parts);
solved Jquery – Split a string(credit card number) in 4 groups [duplicate]