I'm trying to replace *[URL]www.link.com[/URL]* with HTML with this regexp:

topic.text = re.sub("(\[URL\])(.*)(\[\/URL\])", '<a href="$2">$2</a>', topic
.text, flags=re.I)

But it's giving me the following problems:

   1. The $2 capture group is only able to be repeated once, so I get 
   <a href="www.link.com">$2</a>
   instead of 
   <a href="www.link.com">www.link.com</a>
   2. Only the first *[URL]* is matched. Everything after the first *[/URL]* 
   is simply deleted...
   
I hope someone can help me with this. I'm using Python 2.7 if it makes a 
difference.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fce5a726-8a4c-455a-a978-6ee70d66464e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to