re question

Schüle Daniel uval at rz.uni-karlsruhe.de
Mon Jul 10 10:10:28 EDT 2006


Hello,

consider the following code

 >>> re.search("[a-z](?i)[a-z]","AA")
<_sre.SRE_Match object at 0x40177e20>

this gives a match
if we provide an extra group for the first character it still works

 >>> re.search("([a-z])(?i)[a-z]","AA").group(1)
'A'
 >>>

it doesn't matter where (?i) is placed, right?
the re engine would glance at once on the entire pattern string
analize it (complain if pattern doesn't make sense, eg invalid)
and it would be the same as if the option was given expicitely
as re.IGNORECASE.

Is there a way to switch-off the option resp.
switch-on the option in the middle of the pattern?

Regards, Daniel



More information about the Python-list mailing list