Replace URL with a link using regex in python
- by user122750
how do I convert some text to a link? Back in PHP, I used this piece of code that worked well for my purpose:
$text = preg_replace("#(^|[\n ])(([\w]+?://[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\3</a>", $text);
$text = preg_replace("#(^|[\n…