Python: Parsing Strings

C

crayfishcray

Guest
So I have strings that form concatenated 1's and 0's with length 12. Here are some examples:

100010011100
001111110000
001010100011


I want to isolate sections of each which start with 1, following with any numbers of zeros, and then ends with 1.

So for the first string, I would want ['10001','1001']

The second string, I would want nothing returned

The third list, I would want ['101','101','10001']

I've tried using a combination of positive lookahead and positive lookbehind, but it isn't working. This is what I've come up with so far [(?<=1)0][0(?=1)]

Continue reading...
 
Top