Algorithm for finding all the combinations on a boolean array I have to design an algorithm to do the next task:

I have one array of booleans. For example:

Array:   [0 1 0 0 1 0 1 1]

I want to obtain all the existing combinations of 1's, having in mind that it is allowed only a maximum of one 0 between 1's.
For example, in the previous case, we would have the outputs (I am using the indices now):
[1] and [4,5,6,7].

But also it should include [4], [6], [7], [4,5,6], [6,7].

Another example:

Array:   [0 1 0 1 0 1 0 0 1]

The output would be: [1], [3], [5]. [8], [1,2,3], [1,2,3,4,5], [3,4,5].

Can you imagine any approach to solve this? The combination explosion could be quite big.

Thank you very much in advance.
The pattern you're trying to match is regular and can be matched by the regular expression 1(0?1)*.  A good strategy would be to convert the binary array to a string and do regular expression matches over substrings of it.

There aren't an exponential number of bit strings to check.  For a string of length $n$, you only have to check 1 string of that length.  You then check 2 strings of length $n - 1$, 3 strings of length $n - 2$ and so on.  In total there are $n(n+1)/2$ strings to check.