Output:use Regexp::Common qw /URI/; my $re_a_tag = qr/<a\s+.*?>.*<\/a>/si ; my $html = q` some link: <a href="http://www.perl.com">www.perl.com</a> http://www.perlmonks.com by! `; my @chunks = split(/($re_a_tag)/si , $html) ; foreach my $chunks_i ( @chunks ) { next if $chunks_i =~ /$re_a_tag/ ; $chunks_i =~ s/($RE{URI}{HTTP})/<a href="$1">$1<\/a>/gsi ; } $html = join('' , @chunks) ; print "$html\n" ;
Enjoy!some link: <a href="http://www.perl.com">www.perl.com</a> <a href="http://www.perlmonks.com">http://www.perlmonks.com</a> by!
By gmpassos
In reply to Re: How to recognize url in text and convert to hyperlink, unless already in anchor
by Anonymous Monk
in thread How to recognize url in text and convert to hyperlink, unless already in anchor
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |