replacing a part of a string using a regexp
Rajarshi Guha
rajarshi at presidency.com
Thu Jul 18 16:20:45 EDT 2002
Hi,
I'm trying to parse some HTML tags and I have the following situation:
a line contains:
<a href="www.myurl.com">
And I want to replace the url and make the line:
<a href="http://myserver.com/prog.py?www.myurl.com">
Using re.sub I can substitute the whole string bewteen quotes, but the
substituion needs to use the string that is *found* in the quotes.
How can I access the matched portion in a re.sub() expression?
TIA
More information about the Python-list
mailing list