Re: Splitting a sequence into pieces with identical elements

2010-08-10 Thread Tim Chase
On 08/10/10 20:30, MRAB wrote: Tim Chase wrote: r = re.compile(r'((.)\1*)') #r = re.compile(r'((\w)\1*)') That should be \2, not \1. Alternatively: r = re.compile(r'(.)\1*') Doh, I had played with both and mis-transcribed the combination of them into one malfunctioning regexp.

Re: Splitting a sequence into pieces with identical elements

2010-08-10 Thread MRAB
Tim Chase wrote: On 08/10/10 19:37, candide wrote: Suppose you have a sequence s , a string for say, for instance this one : spppaeggg We want to split s into the following parts : ['s', 'ppp', 'a', '', 'e', 'ggg', ''] ie each part is a single repeated character word. Whi

Re: Splitting a sequence into pieces with identical elements

2010-08-10 Thread Tim Chase
On 08/10/10 19:37, candide wrote: Suppose you have a sequence s , a string for say, for instance this one : spppaeggg We want to split s into the following parts : ['s', 'ppp', 'a', '', 'e', 'ggg', ''] ie each part is a single repeated character word. While I'm not sure it'

Re: Splitting a sequence into pieces with identical elements

2010-08-10 Thread Chris Rebert
On Tue, Aug 10, 2010 at 5:37 PM, candide wrote: > Suppose you have a sequence s , a string  for say, for instance this one : > > spppaeggg > > We want to split s into the following parts : > > ['s', 'ppp', 'a', '', 'e', 'ggg', ''] > > ie each part is a single repeated character wor

Splitting a sequence into pieces with identical elements

2010-08-10 Thread candide
Suppose you have a sequence s , a string for say, for instance this one : spppaeggg We want to split s into the following parts : ['s', 'ppp', 'a', '', 'e', 'ggg', ''] ie each part is a single repeated character word. What is the pythonic way to answer this question? A naive