RegEx Consecutive Matches Help

Let’s say there’s a string = “4556 6789”

I want to find all matches of consecutive digits and I use the regex “\d\d” for that. However, it only returns 4 matches (45,56, 67, 89). Expected output is 6 matches (45, 55, 56, 67, 78, 89). How do I achieve that?

In Javascript, you can use lookaheads with capture groups on String.prototype.matchAll, then convert the resulting iterator with Array.from:

const s = "4556 6789";
matches = Array.from(s.matchAll(/(?=(\d\d))/g), (match) => match[1]);
console.log(matches);

Result:
["45", "55", "56", "67", "78", "89"]

The following link gives a good overview:

So it seems what you really want is all the 2 digits numbers and not consecutive numbers. Because consecutive numbers would include 455, 4556, 556, 678, 6789, and 789.