[Numpy-discussion] String manipulation

Alan G Isaac aisaac at american.edu
Mon May 11 10:41:11 EDT 2009


On 5/11/2009 8:03 AM Nils Wagner apparently wrote:
>>>> line_a
> '12345678abcdefgh12345678'
> Is it possible to split line_a such that the output
> is
> 
> ['12345678', 'abcdefgh', '12345678']


More of a comp.lang.python question, I think:

out = list()
for k, g in groupby('123abc456',lambda x: x.isalpha()): out.append( ''.join(g) )

fwiw,
Alan Isaac




More information about the NumPy-Discussion mailing list