Re: [Tutor] unpack/regexp

2006-04-11 Thread doug shawhan
I always slice the string  in this sort of situation: s = "12345678901234567890123456789012 " t = s[:10],s[10:20],s[20:-1]     print t ('1234567890', '1234567890', '123456789012') One could always bracket it to make a list or whatever. Hope this helps! On 4/11/06, Paul Kraus <[EMAIL PROTECT

Re: [Tutor] unpack/regexp

2006-04-11 Thread Paul Kraus
> Python regex is a bit more verbose than Perl but you can do the same thing: > > In [2]: import re > > In [11]: m=re.match("(.{10})(.{10})(.{13})", line) > > In [13]: m.group(1, 2, 3) > Out[13]: ('1234567890', '1234567890', '123456789012 ') That work great. Regex tend to be "expensive" is there a

Re: [Tutor] unpack/regexp

2006-04-11 Thread Kent Johnson
Paul Kraus wrote: > Ok sorry for the perl refernce but I can't figure out how to do this. > I have a fixed width text file i need to parse. > > so lets say I want an array to containt the pieces i need. > if the fields I want are lengths from left to right. > 10 10 13 > 123456789012345678901234567

[Tutor] unpack/regexp

2006-04-11 Thread Paul Kraus
Ok sorry for the perl refernce but I can't figure out how to do this. I have a fixed width text file i need to parse. so lets say I want an array to containt the pieces i need. if the fields I want are lengths from left to right. 10 10 13 12345678901234567890123456789012 I want to turn this into a