Different number of matches from re.findall and re.split
jlconlin at gmail.com
Mon Jan 11 20:19:03 CET 2010
On Jan 11, 9:28 am, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> MRAB <pyt... at mrabarnett.plus.com> 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 instead:
> > tables = re.compile('^ 1', re.MULTILINE).split(line)
> or you might include the flag in the regular expression literal: '(?m)^ 1'
Another great solution. This is what I will do.
More information about the Python-list