How to find the length of consecutive zeros that is surrounded by ones at both ends of a binary?
For example, in 10010001 the 2 matches are 1001 and 10001
- 1001 the length of zeroes is 2
- 10001 the length of zeroes is 3
I used match which returned only the last one i.e. 10001.
'1010001'.match(/1(0+)1$/g)