Regex problem ...

Barghest barghest at wanadoo.fr
Wed Mar 27 04:33:28 EST 2002


Hello,
import re
tagImg = re.compile( r"""(<img\s+src=")\.\./Images/([^"]*)("[^>]*>)""",
re.IGNORECASE | re.MULTILINE | re.DOTALL )

Wanna match ... <img src="../images/FOO.gif" height="12" etc...> and replace
it by
<img src="foo.gif" height="12" ...>

the problem is that i don't know how to lowercase the \g<2> part
bp2.write( tagImg.sub( '\g<1>\g<2>\g<3>', buff ) )

I tried
tagImg.sub( string.lower( '\g<1>\g<2>\g<3>' ), buff )
but it doesen't work ..

Any idea ?





More information about the Python-list mailing list