I have a string like this: 56f7gg5cx887r7gt8r6t7
.
Besides splitting it into an array of one and then looping by two i+2
and creating another array with entries containing two by two.
Is there a simpler way?
The result should be like this: ['56','f7','gg','5c','x8','87','r7','gt','8r','6t','7']
.
You can use match:
'56f7gg5cx887r7gt8r6t7'.match(/(..?)/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