I'm trying to replace [URL]www.link.com[/URL] with HTML with this regexp:
But it's giving me the following problems:
-- topic.text = re.sub("(\[URL\])(.*)(\[\/URL\])", '<a href="$2">$2</a>', topic.text, flags=re.I)But it's giving me the following problems:
- The $2 capture group is only able to be repeated once, so I get instead of<a href="www.link.com">$2</a><a href="www.link.com">www.link.com</a>
- Only the first [URL] is matched. Everything after the first [/URL] is simply deleted...
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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.
No comments:
Post a Comment