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
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';
console.log(str.replace(/([\d.]+)/g, ' $1 ').replace(/^ +| +$/g, ''));
result = subject.replace(/[a-z](?=[0-9])|[0-9](?=[a-z])/ig, "$& ");
This matches a letter that's followed by a digit, or a digit that's followed by a letter, without consuming the second character. Then it replaces the first character with the same character followed by a space.