How to convert urls to text in html links?

I am writing a discussion on a forum such as a forum in Perl and would like to automatically change http://www.google.com as an HTML link. It should also be safe and fallible in terms of security. Is there a quick, easy, and safe way to add links automatically?

+3
source share
1 answer

Try something like this:

use Regexp::Common qw /URI/;

$text =~ s|($RE{URI}{HTTP})(?!</a>)|<a href="$1">$1</a>|g

Regexp:: Common:: URI, , , URL-, , . , , URL- . , , - - :

<a href="http://www.mysite.com">http://www.mysite.com is my website</a>

, URL-, .

+8

Source: https://habr.com/ru/post/1707947/


All Articles