Issue 1022030: re.match(), re.MULTILINE and "^" broken (original) (raw)
The re.match() function does not appear to respect the re.MULTILINE flag when matching on "^". It does, however, behave as documented with respect to "$". I've observed this with Python 2.2.2 and 2.3.3 on Linux, RedHat 9.0. Below is some sample code and output that illustrates the issue. As illustrated, re.search() behaves as expected.
$ cat /proc/version Linux version 2.4.20-28.9psycho (root@sahp5069) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 SMP Wed Feb 18 07: 08:55 MST 2004
$ python Python 2.2.2 (#1, Feb 10 2004, 13:57:46) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
$ python re_bug.py Pattern is '^hello world$' with flags = 10 Testing: "hello world thank you"... match_pass search_pass Testing: "ahem hello world"... match_fail search_pass Testing: "ahem hello world thank you"... match_fail search_pass
I would expect the match to work (match_pass and search_pass) on all of the sample strings.