[Python-bugs-list] [Bug #127259] New re breaks on some '*?' matches
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 02 Jan 2001 05:23:54 -0800
Bug #127259, was updated on 2001-Jan-01 20:37
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 : effbot
Summary: New re breaks on some '*?' matches
Details: New python library:
Python 2.0 (#2, Nov 29 2000, 07:33:50)
[GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match("a[ ]*?\ (\d+)", "a 10")
<SRE_Match object at 0x81db748>
>>> re.match("a[ ]*?\ (\d+)", "a 10")
Old python library:
Python 1.5.2 (#1, Aug 25 2000, 09:33:37) [GCC 2.96 20000731
(experimental)] on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import re
>>> re.match("a[ ]*?\ (\d+)", "a 10")
<re.MatchObject instance at 80dc1e0>
>>> re.match("a[ ]*?\ (\d+)", "a 10")
<re.MatchObject instance at 80d9c88>
>>>
I see no reason why the second line should not match. (IE.
the old regular expression library seems correct to me.)
Ok, "so don't do that" - well I encountered it in code that
autogenerates regular expressions, so it isn't so easy to
always avoid. Besides, it doesn't look correct to me.
Thanks,
-Kevin (kevoc@bellatlantic.net)
Follow-Ups:
Date: 2001-Jan-02 05:23
By: gvanrossum
Comment:
Also note that if you increase the number of spaces between 'a' and '10',
sre gives a match for an odd number of spaces only.
-------------------------------------------------------
Date: 2001-Jan-01 21:20
By: tim_one
Comment:
Reproduced and assigned to /F. Agree it's a bug. Also agree you shouldn't
do that <wink>.
SourceForge's treatment of whitespace is maddening. Note that there
*should* be 3 blanks in "a 10" (first example) but 4 in "a 10"
(second, failing example).
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=127259&group_id=5470