Getting all possible consecutive 4 digit numbers from a 10 digit number

Viewed 361

I am trying to make a regex to get all the possible consecutive 4 digit numbers from a 10 digit number. Like

num = "2345678901";

Output : 2345, 3456, 4567, 5678, 6789, 7890, 8901

These simple regex are not working:

[\d]{4}
(\d\d\d\d)
2 Answers
Related