Question on re.IGNORECASE

chemag at gmail.com chemag at gmail.com
Thu Oct 20 14:55:44 EDT 2005


Hi,

I'm having some problems with basic RE in python. I was wondering
whether
somebody could provide a hint on what's going wrong with the following
script. Comments are included.

TIA.
-myself

> python2.3
Python 2.3.4 (#1, Nov 18 2004, 13:39:30)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> pattern = re.compile('.*HTTP/(\d\.\d) *(\d*) *(.*)$')
>>> pattern.search("GGHTTP/1.1 200 OK\r\n", re.IGNORECASE)
<_sre.SRE_Match object at 0xb75c6ed0>
>>> pattern.search("GHTTP/1.1 200 OK\r\n", re.IGNORECASE)
# this makes no sense to me. Why is the previous line matched
# and this not?
>>> pattern.search("GHTTP/1.1 200 OK\r\n")
<_sre.SRE_Match object at 0xb758d020>




More information about the Python-list mailing list