[Python-bugs-list] [Bug #128823] uncompatible re.findall() with the new engine = "sre"
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 15 Jan 2001 02:07:52 -0800
Bug #128823, was updated on 2001-Jan-15 02:07
Here is a current snapshot of the bug.
Project: Python
Category: Regular Expressions
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: nobody
Assigned to : nobody
Summary: uncompatible re.findall() with the new engine = "sre"
Details: The following example code:
-------------------------------------
import re
strA = ('1,"2",1,3')
strB = ('1,"2","2",3')
# from Perl cookbook for parsing CSV lines:
pattern = r'"([^\"\\]*(?:\\.[^\"\\]*)*)",?|([^,]+),?|,'
lstA = re.findall(pattern,strA)
for tupl in lstA:
print tupl
print
lstB = re.findall(pattern,strB)
for tupl in lstB:
print tupl
-------------------------------------
produces the following (correct) input for re.engine = "pre":
('', '1')
('2', '')
('', '1')
('', '3')
('', '1')
('2', '')
('2', '')
('', '3')
and the following (STRANGE!) output for re.engine = "sre":
('', '1')
('2', '1')
('2', '1')
('2', '3')
('', '1')
('2', '1')
('2', '1')
('2', '3')
It seems as the matching group's value don't reset between the iterations
of findall().
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=128823&group_id=5470