use strict;
my $str = ':smile: :thumbs_up: :+1: :-1:
but NOT if the colons are part of the url, like this URL for example: http://pdf.reuters.com/htmlnews/htmlnews.asp?i=43059c3bf0e37541&u=urn:newsml:reuters.com:20190417:nPn5XHnXBa
I was browsing and found this url :smile: http://pdf.reuters.com/htmlnews/htmlnews.asp?i=43059c3bf0e37541&u=urn:newsml:reuters.com:20190417:nPn5XHnXBa it\'s fantastic :smile::+1: Remember: don\'t forget to upvote!';
my $regex = qr/(https?://\S+)|:[\w+-]+:/mp;
my $subst = '\\1';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html