Im having some strings like these
aa11b2s
abc1sff3
a1b1sdd2
etc.... i need to change these strings to these
aa 11 b 2 s
abc 1 sff 3
a 1 b 1 sdd 2
Simply saying..i need to add a space between each(number/alphabetic s) blocks
var str = 'aa11b2s'.replace(/([a-z]+|\d+)(?!$)/gi, '$1 ');
var str = 'aa11b2s';
console.log(str.replace(/([\d.]+)/g, ' $1 ').replace(/^ +| +$/g, ''));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With