On Sat, Aug 22, 2009 at 3:45 PM, Luke Stebbing<[email protected]> wrote: >>>> import re >>>> re.split(r'(AB+)', 'ABABBABBBABBBBABBBBBABBBBBB') > ['', 'AB', '', 'ABB', '', 'ABBB', '', 'ABBBB', '', 'ABBBBB', '', 'ABBBBBB', > ''] > > Luke >
or, you can use re.findall if you want to avoid the empty strings in
the first and last positions.
>>> print re.findall('(AB+)', 'ABABBABBBABBBBABBBBBABBBBBB')
['AB', 'ABB', 'ABBB', 'ABBBB', 'ABBBBB', 'ABBBBBB']
bryan
