small problem with re.sub
- From: Astan Chee <stanc@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 14:01:30 +1100
Hi,
I have a html text stored as a string. Now I want to go through this string and find all 6 digit numbers and make links from them.
Im using re.sub and for some reason its not picking up the previously matched condition. Am I doing something wrong? This is what my code looks like:
htmlStr = re.sub('(?P<id>\d{6})','<a href=\"http://linky.com/(?P=id).html\">(?P=id)</a>',htmlStr)
It seems that it replaces it alright, but it replaces it literally. Am I not escaping certain characters?
Thanks again for the help.
Cheers
Animal Logic
http://www.animallogic.com
Please think of the environment before printing this email.
This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free.
.
- Follow-Ups:
- Re: small problem with re.sub
- From: Mark Tolonen
- Re: small problem with re.sub
- Prev by Date: Re: REALLY simple xml reader
- Next by Date: Re: Has Anyone Worked with Gene Expression Programming ???????????????????????????
- Previous by thread: Re: Why the HELL has nobody answered my question !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- Next by thread: Re: small problem with re.sub
- Index(es):
Relevant Pages
|