[Python-bugs-list] bug in the module re (PR#184)

st99@mail.ru st99@mail.ru
Mon, 17 Jan 2000 08:30:02 -0500 (EST)


Full_Name: Sultanbek Tezadov
Version: 1.5.2
OS: Linux, Win32
Submission from: minas.rosmail.com (195.90.128.115)


There is a bug in the re module: in MULTILINE and DOTALL mode 
the .*? pattern is greedy for newlines (^). E.g.:
>>> import re
>>> s = """\
...   line 1
...   line 2
...   ...
...   line n
... """
>>> def f(s, p):
...   print re.search(p, s).group(1)
...
>>> p = r'(?m)(^.*?2)' # it works okay
>>> f(s, p)
  line 2
>>> p = r'(?ms)(^.*?2)' # but for some reasons I need DOTALL mode as well
>>> f(s, p) # I expect the same output as before, but I get:
  line 1
  line 2
>>>

I got it both on Linux and Win32.