[Python-bugs-list] [ python-Bugs-477728 ] .*? matches newlines without DOTALL
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 06 Dec 2001 14:07:12 -0800
Bugs item #477728, was opened at 2001-11-02 22:04
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=477728&group_id=5470
Category: Regular Expressions
Group: Python 2.2
Status: Open
Resolution: None
Priority: 7
Submitted By: Tim Peters (tim_one)
Assigned to: Fredrik Lundh (effbot)
Summary: .*? matches newlines without DOTALL
Initial Comment:
ython 2.2b1+ (#25, Oct 30 2001, 22:36:33) [MSC 32 bit
(Intel)] on win32
>> text = "one\ntwo\nthree\n"
>> import re
>> re.match(r'.*?$', text)
SRE_Match object at 0x007AD940>
>> _.group(0) # oops!
one\ntwo\nthree'
>> re.match(r'.*$', text) # more like it
>>
Since . shouldn't match a newline in the absence of
re.DOTALL, .*? shouldn't match any newlines, and then
minimal match should have failed (as did the maximal
match). Found by Bruce Eckel.
----------------------------------------------------------------------
>Comment By: Fredrik Lundh (effbot)
Date: 2001-12-06 14:07
Message:
Logged In: YES
user_id=38376
A quick fix (which I originally planned to check in
tonight) would be to back out of a recent patch that
attempts to avoid recursion in some cases. But after
a careful code review, I'm beginning to think that I
might be able to tweak the patch into something that
works also in this case.
But I better do that some night when I haven't been
out celebrating the PythonWorks 1.3 release...
(tomorrow, in other words)
</F>
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-12-02 12:28
Message:
Logged In: YES
user_id=31435
Boosted priority: /F, what's the hangup here?
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-12-02 12:27
Message:
Logged In: YES
user_id=31435
Boosted priority: /F, what's the hangup here?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=477728&group_id=5470