Re: Different number of matches from re.findall and re.split

2010-01-12 Thread Tim Chase
Steve Holden wrote: Steve Holden wrote: [...] Can someone explain why these two commands are giving different results? I thought I should have the same number of matches (or maybe different by 1, but not 6000!) re.MULTLINE is apprently 1, and you are providing it as the "maxsplit" argument. C

Re: Different number of matches from re.findall and re.split

2010-01-12 Thread Steve Holden
Steve Holden wrote: [...] >> Can someone explain why these two commands are giving different >> results? I thought I should have the same number of matches (or maybe >> different by 1, but not 6000!) >> > re.MULTLINE is apprently 1, and you are providing it as the "maxsplit" > argument. Check the

Re: Different number of matches from re.findall and re.split

2010-01-12 Thread Steve Holden
Jeremy wrote: > Hello all, > > I am using re.split to separate some text into logical structures. > The trouble is that re.split doesn't find everything while re.findall > does; i.e.: > >> found = re.findall('^ 1', line, re.MULTILINE) >> len(found) >6439 >> tables = re.split('^ 1', line, re.M

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Jeremy
On Jan 11, 9:28 am, Duncan Booth wrote: > MRAB wrote: > >> Yep.  Thanks for pointing that out.  I guess I just assumed that > >> re.split was similar to re.search/match/findall in what it accepted as > >> function parameters.  I guess I'll have to use a \n instead of a ^ for > >> split. > > > You

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Steve Holden
Jeremy wrote: > On Jan 11, 8:44 am, Iain King wrote: >> On Jan 11, 3:35 pm, Jeremy wrote: >> >> >> >> >> >>> Hello all, >>> I am using re.split to separate some text into logical structures. >>> The trouble is that re.split doesn't find everything while re.findall >>> does; i.e.: found = re.

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Duncan Booth
MRAB wrote: >> Yep. Thanks for pointing that out. I guess I just assumed that >> re.split was similar to re.search/match/findall in what it accepted as >> function parameters. I guess I'll have to use a \n instead of a ^ for >> split. >> > You could use the .split method of a pattern object i

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Peter Otten
Jeremy wrote: > On Jan 11, 8:44 am, Iain King wrote: >> On Jan 11, 3:35 pm, Jeremy wrote: >> >> >> >> >> >> > Hello all, >> >> > I am using re.split to separate some text into logical structures. >> > The trouble is that re.split doesn't find everything while re.findall >> > does; i.e.: >> >> >

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread MRAB
Jeremy wrote: On Jan 11, 8:44 am, Iain King wrote: On Jan 11, 3:35 pm, Jeremy wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does; i.e.: found = re.findall('^ 1', line, re.MULTILI

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Arnaud Delobelle
On 11 Jan, 15:35, Jeremy wrote: > Hello all, > > I am using re.split to separate some text into logical structures. > The trouble is that re.split doesn't find everything while re.findall > does; i.e.: > > > > > found = re.findall('^ 1', line, re.MULTILINE) > > len(found) >    6439 > > tables = re

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Jeremy
On Jan 11, 8:44 am, Iain King wrote: > On Jan 11, 3:35 pm, Jeremy wrote: > > > > > > > Hello all, > > > I am using re.split to separate some text into logical structures. > > The trouble is that re.split doesn't find everything while re.findall > > does; i.e.: > > > > found = re.findall('^ 1', li

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Iain King
On Jan 11, 3:35 pm, Jeremy wrote: > Hello all, > > I am using re.split to separate some text into logical structures. > The trouble is that re.split doesn't find everything while re.findall > does; i.e.: > > > > > found = re.findall('^ 1', line, re.MULTILINE) > > len(found) >    6439 > > tables =