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

noreply@sourceforge.net noreply@sourceforge.net
Fri, 02 Nov 2001 22:04:18 -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: 6
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.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=477728&group_id=5470