Ruphaa's Notes

How to pair consecutive digits in JS using regex?

js
regex

'11211'.match(/\d{2}/g)

// ["11", "21"]

'11211'.match(/\d{3}/g)

// ["112"]
It will discard the rest of the numbers because, they don't form a 3 digit set