I need to be able to check if a message contains [link] tags and then replace them with the appropriate html code.
E.g.
I am very weak whilst writing regexes and this one has really gone over the top of my head. Any help or links to help would really be appreciated.
Thanks
E.g.
Code:
The link to Google is [link]http://google.com[/url] !!!
=
The link to Google is <a href="[URL unfurl="true"]http://google.com"[/URL] target="_blank">[URL unfurl="true"]http://google.com</a>[/URL] !!!
I am very weak whilst writing regexes and this one has really gone over the top of my head. Any help or links to help would really be appreciated.
Code:
sub command_link {
$link_ = $_[0];
my $link = '<a href="'.$link_.'" target="_blank">'.$link_.'</a>';
return $link;
}
if ($message =~ m/^\[link\](?)+\[\/link\]$/) { $message = command_link(m/^\[link\](.$)\[\/link\]$/); }
Thanks