[Python-bugs-list] [ python-Bugs-477728 ] .*? matches newlines without DOTALL

noreply@sourceforge.net noreply@sourceforge.net
Sun, 02 Dec 2001 12:28:47 -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: 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