javascript split string at at two different indexes

I don't really see the need for regular expressions here. If you know the indexes you need to split on, you can just do this:

var input = '371449635398431'
var part1 = input.substr(0, 4);
var part2 = input.substr(4, 6);
var part3 = input.substr(10);

But if a regular expression is a must, you can do this:

var input = '371449635398431'
var match = /^(\d{4})(\d{6})(\d{5})$/.exec(input);
var part1 = match[1];
var part2 = match[2];
var part3 = match[3];

To insert spaces between each part you can do this:

var match = input.substr(0, 4) + ' ' + input.substr(4, 6) + ' ' + input.substr(10);

Or this:

var match = [ input.substr(0, 4), input.substr(4, 6), input.substr(10) ].join(' ');

Or this (inspired by Arun P Johny's answer):

var match = /^(\d{4})(\d{6})(\d{5})$/.exec(input).slice(1).join(' ');

Or this:

var match = input.replace(/^(\d{4})(\d{6})(\d{5})$/, '$1 $2 $3');

Try

var array = '371449635398431'.match(/(\d{4})(\d{6})(\d{5})/).splice(1)