I have a number string, eg. 123456789
I want to split them four in a group, such that it would be 1 2345 6789
.
I tried with
string.match(/.{1, 4}/g).join(' ');
but it only gives 1234 5678 9
I also tried to reverse it first,
string.split('').reverse().join('').match(/.{1,4}/g).join(' ')
but it gives 1 5432 9876
instead...
any hints?