Different number of matches from re.findall and re.split
Duncan Booth
duncan.booth at invalid.invalid
Mon Jan 11 11:28:54 EST 2010
MRAB <python 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'
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list