Different number of matches from re.findall and re.split
steve at holdenweb.com
Tue Jan 12 11:33:02 CET 2010
> 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)
>> tables = re.split('^ 1', line, re.MULTILINE)
> 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 API in the documentation.
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
More information about the Python-list