I have random strings that are similar to this:
2d4hk8x37m
or whatever. I need to split it at every other character.
To split it at every character its simply:
'2d4hk8x37m'.split('');
But i need every other character so the array would be like this:
['2d', '4h', 'k8', 'x3', '7m']
var string = "2d4hk8x37m";
var matches = string.match(/.{2}/g);
console.log(matches);
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