[Tutor] problem in replacing regex

Kumar hihiren1 at gmail.com
Mon Apr 6 16:23:25 CEST 2009

Hello everyone,

I have one account number. I want to replace all this account numbers and
convert them as URLS.

but I don't want to convert existing urls which has account numbers.

e.g. 1234-4578
first i convert any existing url into <a> and then I check that if any above
number exist then I convert them to my site's url .

i am already having regex to check and replace this number. And I can
replace all occurrences of this number and convert them into url using
but problem is that if the value is http://sadfsdf.com/1234-4578 then it
first converts http://sadfsdf.com/1234-4578 into <a href="
http://sadfsdf.com/1234-4578">http://sadfsdf.com/1234-4578</a> and then
again it converts last number into url so the complete url gets broken.

can anybody help me how can I omit the searching existing urls with above

I have already tried many examples but none of them seems working. Although
I can use re.sub('[^/](myregex)','<desirect replacement>',value) but it
won't be a permenant solution as if somebody enters /1234-4578 then also it
won't convert it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090406/8612a1b7/attachment.htm>

More information about the Tutor mailing list