$string = "http://www.yahoo.com"
$string =~ s{
\b # start of the word
(
https?://[a-z0-9]+(\.[a-z0-9]+)*\.(com|edu|info)
\b #end of the word
(
/[a-z0-9_:\@&?=+,.!/~*'%\$]*#optional part that catch for example http://www.yahoo.com/mail/Inbox
(?<![.,?!]) # Not allowed to end with [.,?!] - negative look behind technique
)
?
)
}{<a href="$1">$1</a>}gix;
The results is <a href="http://www.yahoo.com">http://www.yahoo.com</a>
No comments:
Post a Comment